From 7e5130c49a90f88ee1ebfda3776052f8fa93c2a4 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 2 Jun 2022 01:43:31 -0400 Subject: [PATCH] Don't wait to add listener --- src/background.ts | 8 +++++--- src/config.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/background.ts b/src/background.ts index d17c1e16..d576fba1 100644 --- a/src/background.ts +++ b/src/background.ts @@ -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); diff --git a/src/config.ts b/src/config.ts index 14034f09..fbb7ece7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -287,7 +287,7 @@ const Config: SBObject = { }, localDefaults: { downvotedSegments: {}, - navigationApiAvailable: null, + navigationApiAvailable: null }, cachedSyncConfig: null, cachedLocalStorage: null,