From 769b8da664be2353bc2e3418789dc404bfde0a26 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 16 Mar 2023 07:13:27 -0400 Subject: [PATCH] Finalize "unreadiness" toolbar icon - Yellow uBO toolbar icon: uBO not ready - Yellow uBO toolbar icon + `!` badge: network requests went through while uBO is not ready --- platform/common/vapi-background.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/platform/common/vapi-background.js b/platform/common/vapi-background.js index 899abc752..dddccdf0f 100644 --- a/platform/common/vapi-background.js +++ b/platform/common/vapi-background.js @@ -809,7 +809,7 @@ if ( webext.browserAction instanceof Object ) { } }; - vAPI.setDefaultIcon = function(flavor) { + vAPI.setDefaultIcon = function(flavor, badge) { if ( browserAction.setIcon === undefined ) { return; } browserAction.setIcon({ path: { @@ -817,6 +817,7 @@ if ( webext.browserAction instanceof Object ) { '32': `img/icon_32${flavor}.png`, } }); + browserAction.setBadgeText({ text: badge }); }; } @@ -1188,6 +1189,8 @@ vAPI.Net = class { this.denormalizeFilters({ urls: [ 'http://*/*', 'https://*/*' ] }), [ 'blocking' ] ); + + vAPI.setDefaultIcon('-loading', ''); } setOptions(/* options */) { } @@ -1231,16 +1234,11 @@ vAPI.Net = class { if ( this.suspendableListener !== undefined ) { return this.suspendableListener(details); } - if ( this.unprocessedRequestCount === 0 ) { - vAPI.setDefaultIcon('-loading'); - } - this.unprocessedRequestCount += 1; + this.onUnprocessedRequest(); } setSuspendableListener(listener) { this.suspendableListener = listener; - if ( this.unprocessedRequestCount !== 0 ) { - vAPI.setDefaultIcon(''); - } + vAPI.setDefaultIcon('', ''); } removeListener(which, clientListener) { const actualListener = this.listenerMap.get(clientListener); @@ -1256,6 +1254,12 @@ vAPI.Net = class { this.listenerMap.set(clientListener, actualListener); return actualListener; } + onUnprocessedRequest() { + if ( this.unprocessedRequestCount === 0 ) { + vAPI.setDefaultIcon('-loading', '!'); + } + this.unprocessedRequestCount += 1; + } suspendOneRequest() { } unsuspendAllRequests() {