1- import { kDisableAll , kInstall } from '/js/consts' ;
1+ import { kDisableAll } from '/js/consts' ;
22import { subscribe , __values as __prefs } from '/js/prefs' ;
33import { CHROME , FIREFOX , MOBILE , VIVALDI } from '/js/ua' ;
44import { debounce } from '/js/util' ;
55import { ignoreChromeError , MF_ICON_EXT , MF_ICON_PATH } from '/js/util-webext' ;
66import * as colorScheme from './color-scheme' ;
7- import { bgBusy , bgPreInit } from './common' ;
7+ import { bgBusy , bgInit } from './common' ;
88import { removePreloadedStyles } from './style-via-webrequest' ;
99import * as tabMan from './tab-manager' ;
1010
@@ -27,9 +27,17 @@ const kShowBadge = 'show-badge';
2727// https://github.com/openstyles/stylus/issues/335
2828let hasCanvas = FIREFOX_ANDROID ? false : null ;
2929
30+ bgInit . push ( initIcons ) ;
3031
31- bgBusy . then ( ( ) => {
32- const runNow = ! __ . MV3 || bgPreInit . includes ( kInstall ) ;
32+ export async function refreshIconsWhenReady ( ) {
33+ if ( bgBusy ) {
34+ bgInit [ bgInit . indexOf ( initIcons ) ] = 0 ;
35+ await bgBusy ;
36+ }
37+ initIcons ( true ) ;
38+ }
39+
40+ function initIcons ( runNow = ! __ . MV3 ) {
3341 colorScheme . onChange ( ( ) => {
3442 if ( __prefs [ kIconset ] === - 1 ) {
3543 debounce ( refreshGlobalIcon ) ;
@@ -47,7 +55,7 @@ bgBusy.then(() => {
4755 kDisableAll ,
4856 kIconset ,
4957 ] , ( ) => debounce ( refreshAllIcons ) , runNow ) ;
50- } ) ;
58+ }
5159
5260tabMan . onUnload . add ( ( tabId , frameId , port ) => {
5361 if ( frameId && tabMan . getStyleIds ( tabId ) ) {
0 commit comments