Skip to content

Commit

Permalink
Restore sidebar contents from cache correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 24, 2024
1 parent 32a72ad commit 47d7cd0
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions webextensions/sidebar/sidebar-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,13 @@ export async function tryPreload(tab = null) {
}

async function preload(tab) {
const cache = await Promise.all([
browser.sessions.getWindowValue(tab.windowId, Constants.kWINDOW_STATE_CACHED_SIDEBAR),
browser.sessions.getWindowValue(tab.windowId, Constants.kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY),
browser.sessions.getWindowValue(tab.windowId, Constants.kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY),
browser.sessions.getTabValue(tab.id, Constants.kWINDOW_STATE_CACHED_SIDEBAR),
browser.sessions.getTabValue(tab.id, Constants.kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY),
browser.sessions.getTabValue(tab.id, Constants.kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY)
]).catch(ApiTabs.createErrorSuppressor());
if (!cache)
return;
mPreloadedCaches.set(`window${tab.windowId}`, cache.slice(0, 2));
mPreloadedCaches.set(`tab${tab.id}`, cache.slice(3, 5));
mTargetWindow = tab.windowId;
const cache = await MetricsData.addAsync('preload: reading window cache', Promise.all([
getWindowCache(Constants.kWINDOW_STATE_CACHED_SIDEBAR),
getWindowCache(Constants.kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY),
getWindowCache(Constants.kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY),
]).catch(ApiTabs.createErrorSuppressor()));
mPreloadedCaches.set(`window${mTargetWindow}`, cache);
}

export async function getEffectiveWindowCache(options = {}) {
Expand Down

0 comments on commit 47d7cd0

Please sign in to comment.