Skip to content

Commit

Permalink
Recreate tab objects when extension installed. (#1463)
Browse files Browse the repository at this point in the history
- On service worker restart we'll restore the tab state
- On update/install we create the tab objects fresh
  • Loading branch information
jonathanKingston committed Oct 21, 2022
1 parent 3cdba0f commit b172e90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion shared/js/background/startup.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export async function onStartup () {
const tab = savedTabs[i]

if (tab.url) {
tabManager.restore(tab.id)
// On reinstall we wish to create the tab again
await tabManager.restoreOrCreate(tab)
}
}

Expand Down
8 changes: 8 additions & 0 deletions shared/js/background/tab-manager.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ class TabManager {
return newTab
}

async restoreOrCreate (tabData) {
const restored = await this.restore(tabData.id)
if (!restored) {
await this.create(tabData)
}
}

async restore (tabId) {
const restoredState = await Tab.restore(tabId)
if (restoredState) {
this.tabContainer[tabId] = restoredState
}
return restoredState
}

delete (id) {
Expand Down

0 comments on commit b172e90

Please sign in to comment.