Don't wait to add listener

This commit is contained in:
Ajay
2022-06-02 01:43:31 -04:00
parent 9b9ea39260
commit 7e5130c49a
2 changed files with 6 additions and 4 deletions

View File

@@ -41,10 +41,12 @@ function onNavigationApiAvailableChange(changes: {[key: string]: chrome.storage.
// If Navigation API is not supported, then background has to inform content script about video change.
// This happens on Safari, Firefox, and Chromium 101 (inclusive) and below.
chrome.tabs.onUpdated.addListener(onTabUpdatedListener);
utils.wait(() => Config.local !== null).then(() => {
if (!Config.local.navigationApiAvailable)
chrome.tabs.onUpdated.addListener(onTabUpdatedListener);
})
if (Config.local.navigationApiAvailable) {
chrome.tabs.onUpdated.removeListener(onTabUpdatedListener);
}
});
if (!Config.configSyncListeners.includes(onNavigationApiAvailableChange)) {
Config.configSyncListeners.push(onNavigationApiAvailableChange);

View File

@@ -287,7 +287,7 @@ const Config: SBObject = {
},
localDefaults: {
downvotedSegments: {},
navigationApiAvailable: null,
navigationApiAvailable: null
},
cachedSyncConfig: null,
cachedLocalStorage: null,