1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00

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
This commit is contained in:
Raymond Hill 2023-03-16 07:13:27 -04:00
parent 86753c5e69
commit 769b8da664
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -809,7 +809,7 @@ if ( webext.browserAction instanceof Object ) {
} }
}; };
vAPI.setDefaultIcon = function(flavor) { vAPI.setDefaultIcon = function(flavor, badge) {
if ( browserAction.setIcon === undefined ) { return; } if ( browserAction.setIcon === undefined ) { return; }
browserAction.setIcon({ browserAction.setIcon({
path: { path: {
@ -817,6 +817,7 @@ if ( webext.browserAction instanceof Object ) {
'32': `img/icon_32${flavor}.png`, '32': `img/icon_32${flavor}.png`,
} }
}); });
browserAction.setBadgeText({ text: badge });
}; };
} }
@ -1188,6 +1189,8 @@ vAPI.Net = class {
this.denormalizeFilters({ urls: [ 'http://*/*', 'https://*/*' ] }), this.denormalizeFilters({ urls: [ 'http://*/*', 'https://*/*' ] }),
[ 'blocking' ] [ 'blocking' ]
); );
vAPI.setDefaultIcon('-loading', '');
} }
setOptions(/* options */) { setOptions(/* options */) {
} }
@ -1231,16 +1234,11 @@ vAPI.Net = class {
if ( this.suspendableListener !== undefined ) { if ( this.suspendableListener !== undefined ) {
return this.suspendableListener(details); return this.suspendableListener(details);
} }
if ( this.unprocessedRequestCount === 0 ) { this.onUnprocessedRequest();
vAPI.setDefaultIcon('-loading');
}
this.unprocessedRequestCount += 1;
} }
setSuspendableListener(listener) { setSuspendableListener(listener) {
this.suspendableListener = listener; this.suspendableListener = listener;
if ( this.unprocessedRequestCount !== 0 ) { vAPI.setDefaultIcon('', '');
vAPI.setDefaultIcon('');
}
} }
removeListener(which, clientListener) { removeListener(which, clientListener) {
const actualListener = this.listenerMap.get(clientListener); const actualListener = this.listenerMap.get(clientListener);
@ -1256,6 +1254,12 @@ vAPI.Net = class {
this.listenerMap.set(clientListener, actualListener); this.listenerMap.set(clientListener, actualListener);
return actualListener; return actualListener;
} }
onUnprocessedRequest() {
if ( this.unprocessedRequestCount === 0 ) {
vAPI.setDefaultIcon('-loading', '!');
}
this.unprocessedRequestCount += 1;
}
suspendOneRequest() { suspendOneRequest() {
} }
unsuspendAllRequests() { unsuspendAllRequests() {