diff --git a/src/background/sw.ts b/src/background/sw.ts index 665282a..7b1a7b1 100644 --- a/src/background/sw.ts +++ b/src/background/sw.ts @@ -7,6 +7,7 @@ import { } from "../libs/controllers/_open-tabs"; import { getUrlsToPin } from "../libs/models/_pinned-tabs-browser-storage"; import { sleep } from "../libs/utils/_sleep"; +import { getAutoOpenTabs } from "../libs/models/_auto-open-tabs-browser-storage"; const RETRY_SLEEP_MS = 100; // After 5 minutes, give up. @@ -29,6 +30,11 @@ browser.action.onClicked.addListener(async (_tab) => { }); browser.windows.onCreated.addListener(async (window) => { + const autoOpen = await getAutoOpenTabs(); + if (!autoOpen.autoOpenTabsNewWindow) { + return; + } + if (window.type === "normal" && window.id) { const windowID = window.id; for (let i = 0; i <= MAX_RETRIES; i += RETRY_SLEEP_MS) { diff --git a/src/libs/models/_auto-open-tabs-browser-storage.ts b/src/libs/models/_auto-open-tabs-browser-storage.ts index 97ad9d5..b3efa9a 100644 --- a/src/libs/models/_auto-open-tabs-browser-storage.ts +++ b/src/libs/models/_auto-open-tabs-browser-storage.ts @@ -5,7 +5,7 @@ export const AUTO_OPEN_STORAGE_KEY = "auto-open-tabs"; export async function getAutoOpenTabs(): Promise { const result = await browser.storage.sync.get(AUTO_OPEN_STORAGE_KEY); if (result[AUTO_OPEN_STORAGE_KEY]) { - return result[AUTO_OPEN_STORAGE_KEY]; + return result[AUTO_OPEN_STORAGE_KEY] as AutoOpenTabs; } return { diff --git a/src/libs/models/_pinned-tabs-browser-storage.ts b/src/libs/models/_pinned-tabs-browser-storage.ts index beeb256..8b6c44b 100644 --- a/src/libs/models/_pinned-tabs-browser-storage.ts +++ b/src/libs/models/_pinned-tabs-browser-storage.ts @@ -5,7 +5,7 @@ export const URLS_TO_PIN_STORAGE_KEY = "pinned-tabs"; export async function getUrlsToPin(): Promise { const result = await storage.sync.get(URLS_TO_PIN_STORAGE_KEY); if (result[URLS_TO_PIN_STORAGE_KEY]) { - return result[URLS_TO_PIN_STORAGE_KEY]; + return result[URLS_TO_PIN_STORAGE_KEY] as string[]; } return [];