Skip to content

Commit

Permalink
Fix sessions disappearing
Browse files Browse the repository at this point in the history
When Chrome was quit the open saved session mapping in local storage was not being cleaned up which meant that next time Chrome was opened the extension thought it was still unshelved but with a window ID that is no longer being used. Due to the logic in the code this resulted in the session not showing up at all in the UI.

We fix this by running an existing function to remove stale mappings on startup.

Fixes #102.
  • Loading branch information
homostellaris committed Dec 10, 2021
1 parent 289f056 commit 112c355
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import status from './ui/status/index.js'
const debouncedTabChangeListener = debounce(tabChangeListener, 2000)

// Listeners must be at the top-level: https://developer.chrome.com/docs/extensions/mv2/background_migration/#listeners
chrome.runtime.onStartup.addListener(openSavedSessionTracker.removeStaleWindowIds)
chrome.storage.onChanged.addListener(openSavedSessionTracker.removeStaleWindowIds) // TODO: Is this triggered by the onRemoved listener?
chrome.tabs.onUpdated.addListener((_, changeInfo, tab) => debouncedTabChangeListener(onUpdatedListener(tab, changeInfo)))
chrome.tabs.onRemoved.addListener((_, removeInfo) => debouncedTabChangeListener(onRemovedListener(removeInfo)))
chrome.windows.onRemoved.addListener(
openSavedSessionTracker.removeClosedWindowId,
)
chrome.storage.onChanged.addListener(openSavedSessionTracker.removeStaleWindowIds)
chrome.windows.onFocusChanged.addListener(setActionIcon)

async function tabChangeListener (promise) {
Expand Down

0 comments on commit 112c355

Please sign in to comment.