From bec4da4b99e626166027ed4406e738edac3b4061 Mon Sep 17 00:00:00 2001 From: David Tejada Date: Fri, 7 Jul 2023 16:21:13 +0200 Subject: [PATCH] Fix stale tab markers on startup with the browser setting "Continue where you left off" --- src/background/misc/tabMarkers.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/background/misc/tabMarkers.ts b/src/background/misc/tabMarkers.ts index 23e1a57a..a2fecd05 100644 --- a/src/background/misc/tabMarkers.ts +++ b/src/background/misc/tabMarkers.ts @@ -82,4 +82,19 @@ export async function resetTabMarkers() { return tabMarkers; }); + + // We need to reload all "unloaded" tabs in case the user has the setting + // "Continue where you left off" enabled. If we don't those tabs will have an + // invalid tab marker. We can also not reassign the tab markers to those + // "unloaded" tabs since we can't get their title, so we don't know which tab + // marker each one has. + if (!(await retrieve("includeTabMarkers"))) return; + + const tabs = await browser.tabs.query({}); + + await Promise.all( + tabs + .filter((tab) => tab.status === "unloaded") + .map(async (tab) => browser.tabs.reload(tab.id)) + ); }