diff --git a/src/services/windows.actions.ts b/src/services/windows.actions.ts index 09973054..4c265916 100644 --- a/src/services/windows.actions.ts +++ b/src/services/windows.actions.ts @@ -122,20 +122,24 @@ export function closeWindowsPopup(): void { const lockedWindowsTabs: Record = {} export function isWindowTabsLocked(id: ID): boolean | { move: boolean; cache: TabCache[] } { - Logs.info('Windows.isWindowTabsLocked', id, typeof lockedWindowsTabs[id]) const locked = lockedWindowsTabs[id] + Logs.info('Windows.isWindowTabsLocked', id, typeof locked, globalTabsLockCounter) if (locked && locked !== true) { delete lockedWindowsTabs[id] } - return locked ?? false + return locked ?? globalTabsLockCounter > 0 } +let globalTabsLockCounter = 0 + export async function createWithTabs( tabsInfo: ItemInfo[], conf?: browser.windows.CreateData ): Promise { Logs.info('Windows.createWithTabs', tabsInfo.length) + globalTabsLockCounter++ + if (!conf) conf = {} const moveTabs = conf.tabId === MOVEID @@ -172,8 +176,10 @@ export async function createWithTabs( } } Logs.err('Windows: Cannot create window with tabs', err) + globalTabsLockCounter-- return false } + globalTabsLockCounter-- if (!window.id || !window.tabs?.length) return true lockedWindowsTabs[window.id] = true