From 4cd2302bc9676c13a8235d47128a59deaf11bdce Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 5 Apr 2020 03:52:40 -0500 Subject: [PATCH] added logic for stranger notification setting made page content refreshes happen on visibility --- docs/TODO.txt | 1 - static-data/default-plugins/pms/main.py | 3 +++ static-data/www/board/autorefresh.js | 9 ++++++++- static-data/www/mail/mail.js | 8 +++++++- static-data/www/shared/main/stats.js | 8 +++++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index 006f0b02..ed49b915 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -12,7 +12,6 @@ * make node "speed" setting such as when ui is open to reduce bandwidth usage * localization support -* add mark read in mail * add BCC support to mail diff --git a/static-data/default-plugins/pms/main.py b/static-data/default-plugins/pms/main.py index cf03c1b7..4a7753ce 100755 --- a/static-data/default-plugins/pms/main.py +++ b/static-data/default-plugins/pms/main.py @@ -76,4 +76,7 @@ def on_processblocks(api, data=None): if data['block'].decrypted: config.reload() if config.get('mail.notificationSetting', True): + if not config.get('mail.strangersNotification', True): + if not user.isFriend(): + return notifier.notification_with_sound(title="Onionr Mail - New Message", message="From: %s\n\nSubject: %s" % (signer, metadata['subject'])) diff --git a/static-data/www/board/autorefresh.js b/static-data/www/board/autorefresh.js index 066ef301..bb41fde1 100644 --- a/static-data/www/board/autorefresh.js +++ b/static-data/www/board/autorefresh.js @@ -34,4 +34,11 @@ function setupInterval(){ var refreshInterval = setInterval(autoRefresh, 3000) setupInterval() -checkbox.onchange = function(){setupInterval} \ No newline at end of file +checkbox.onchange = function(){setupInterval} + + +document.addEventListener("visibilitychange", function() { + if (document.visibilityState === 'visible') { + autoRefresh() + } + }) diff --git a/static-data/www/mail/mail.js b/static-data/www/mail/mail.js index f83408d0..f693e808 100755 --- a/static-data/www/mail/mail.js +++ b/static-data/www/mail/mail.js @@ -441,4 +441,10 @@ setActiveTab('inbox') setInterval(function(){mailPing()}, 10000) mailPing() window.inboxInterval = setInterval(function(){refreshPms(true)}, 3000) -refreshPms(true) \ No newline at end of file +refreshPms(true) + +document.addEventListener("visibilitychange", function() { + if (document.visibilityState === 'visible') { + refreshPms() + } + }) diff --git a/static-data/www/shared/main/stats.js b/static-data/www/shared/main/stats.js index a33068e4..00f3d2fb 100755 --- a/static-data/www/shared/main/stats.js +++ b/static-data/www/shared/main/stats.js @@ -136,5 +136,11 @@ var getStats = function(){ }) } +document.addEventListener("visibilitychange", function() { + if (document.visibilityState === 'visible') { + getStats() + } + }) + getStats() -setInterval(function(){getStats()}, 10000) \ No newline at end of file +setInterval(function(){getStats()}, 1000) \ No newline at end of file