@@ -86,6 +86,7 @@ async function preload(tab) {
86
86
mTargetWindow = tab . windowId ;
87
87
const cache = await MetricsData . addAsync ( 'preload: reading window cache' , Promise . all ( [
88
88
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ,
89
+ getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ,
89
90
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ,
90
91
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY ) ,
91
92
] ) . catch ( ApiTabs . createErrorSuppressor ( ) ) ) ;
@@ -97,6 +98,7 @@ export async function getEffectiveWindowCache(options = {}) {
97
98
log ( 'getEffectiveWindowCache: start' ) ;
98
99
cancelReservedUpdateCachedTabbar ( ) ; // prevent to break cache before loading
99
100
let cache ;
101
+ let cachedContents ;
100
102
let cachedSignature ;
101
103
let actualSignature ;
102
104
await Promise . all ( [
@@ -109,12 +111,19 @@ export async function getEffectiveWindowCache(options = {}) {
109
111
// [cache, const tabsDirty, const collapsedDirty] = await Promise.all([
110
112
let tabsDirty , collapsedDirty ;
111
113
const preloadedCache = mPreloadedCaches . get ( `window${ mLastWindowCacheOwner . windowId } ` ) ;
112
- [ cache , tabsDirty , collapsedDirty ] = preloadedCache || await MetricsData . addAsync ( 'getEffectiveWindowCache: reading window cache' , Promise . all ( [
114
+ [ cache , cachedContents , tabsDirty , collapsedDirty ] = preloadedCache || await MetricsData . addAsync ( 'getEffectiveWindowCache: reading window cache' , Promise . all ( [
113
115
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ,
116
+ getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ,
114
117
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ,
115
118
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY )
116
119
] ) ) ;
117
120
mPreloadedCaches . clear ( ) ;
121
+ if ( cache && cache . tabbar && cachedContents ) {
122
+ const contents = await cachedContents . text ( ) ;
123
+ const versionPart = contents . match ( / ^ v e r s i o n = ( \d + ) \n / ) ;
124
+ if ( versionPart && versionPart [ 1 ] == cache . version )
125
+ cache . tabbar . contents = contents . replace ( / ^ v e r s i o n = ( \d + ) \n / , '' ) ;
126
+ }
118
127
cachedSignature = cache && cache . signature ;
119
128
log ( `getEffectiveWindowCache: got from the owner ` , mLastWindowCacheOwner , {
120
129
cachedSignature, cache, tabsDirty, collapsedDirty
@@ -467,6 +476,7 @@ function clearWindowCache() {
467
476
if ( ! configs . persistCachedTree )
468
477
clearPersistentWindowCache ( ) ;
469
478
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ;
479
+ updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ;
470
480
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ;
471
481
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY ) ;
472
482
}
@@ -557,13 +567,16 @@ async function updateCachedTabbar() {
557
567
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR , {
558
568
version : kCONTENTS_VERSION ,
559
569
tabbar : {
560
- contents : SidebarTabs . wholeContainer . innerHTML ,
561
570
style : mTabBar . getAttribute ( 'style' ) ,
562
571
pinnedTabsCount : Tab . getPinnedTabs ( mTargetWindow ) . length
563
572
} ,
564
573
indent : Indent . getCacheInfo ( ) ,
565
574
signature
566
575
} ) ;
576
+ updateWindowCache (
577
+ Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ,
578
+ new Blob ( [ `version=${ kCONTENTS_VERSION } \n${ SidebarTabs . wholeContainer . innerHTML } ` ] )
579
+ ) ;
567
580
}
568
581
569
582
0 commit comments