From 454873b6dface006b2bb7e8e8ae259daf0a27f0a Mon Sep 17 00:00:00 2001 From: kkapsner Date: Tue, 21 Aug 2018 21:37:21 +0200 Subject: [PATCH] Render notifications in junks Fixes #234. --- pageAction/pageAction.js | 28 ++++++++++++++++++++-------- releaseNotes.txt | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index 46e7f50..32956a7 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -185,14 +185,26 @@ browser.runtime.onMessage.addListener(function(data){ if (Array.isArray(data["canvasBlocker-notifications"])){ message("got notifications"); - data["canvasBlocker-notifications"].forEach(function(notification){ - verbose(notification); - notification.url = new URL(notification.url); - domainNotification( - notification.url.hostname, - notification.messageId - ).addNotification(new Notification(notification)); - }); + const notifications = data["canvasBlocker-notifications"]; + let i = 0; + const length = notifications.length; + const tick = window.setInterval(function(){ + if (i >= length){ + window.clearInterval(tick); + } + else { + for (var delta = 0; delta < 20 && i + delta < length; delta += 1){ + let notification = notifications[i + delta]; + verbose(notification); + notification.url = new URL(notification.url); + domainNotification( + notification.url.hostname, + notification.messageId + ).addNotification(new Notification(notification)); + } + i += delta; + } + }, 1); } }); message("request notifications from tab", tab.id); diff --git a/releaseNotes.txt b/releaseNotes.txt index b709268..99511ea 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -14,6 +14,7 @@ Version 0.5.3: - detection if the options page was displayed in a separate tab did not work reliably - popup text not readable in some dark themes - display conditions for notification settings + - page action not useable with a lot of notifications known issues: - if a data URL is blocked the page action button does not appear