@@ -84,6 +84,7 @@ async function preload(tab) {
84
84
mTargetWindow = tab . windowId ;
85
85
const cache = await MetricsData . addAsync ( 'preload: reading window cache' , Promise . all ( [
86
86
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ,
87
+ getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ,
87
88
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ,
88
89
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY ) ,
89
90
] ) . catch ( ApiTabs . createErrorSuppressor ( ) ) ) ;
@@ -95,6 +96,7 @@ export async function getEffectiveWindowCache(options = {}) {
95
96
log ( 'getEffectiveWindowCache: start' ) ;
96
97
cancelReservedUpdateCachedTabbar ( ) ; // prevent to break cache before loading
97
98
let cache ;
99
+ let cachedContents ;
98
100
let cachedSignature ;
99
101
let actualSignature ;
100
102
await Promise . all ( [
@@ -107,12 +109,19 @@ export async function getEffectiveWindowCache(options = {}) {
107
109
// [cache, const tabsDirty, const collapsedDirty] = await Promise.all([
108
110
let tabsDirty , collapsedDirty ;
109
111
const preloadedCache = mPreloadedCaches . get ( `window${ mLastWindowCacheOwner . windowId } ` ) ;
110
- [ cache , tabsDirty , collapsedDirty ] = preloadedCache || await MetricsData . addAsync ( 'getEffectiveWindowCache: reading window cache' , Promise . all ( [
112
+ [ cache , cachedContents , tabsDirty , collapsedDirty ] = preloadedCache || await MetricsData . addAsync ( 'getEffectiveWindowCache: reading window cache' , Promise . all ( [
111
113
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ,
114
+ getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ,
112
115
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ,
113
116
getWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY )
114
117
] ) ) ;
115
118
mPreloadedCaches . clear ( ) ;
119
+ if ( cache && cache . tabbar && cachedContents ) {
120
+ const contents = await cachedContents . text ( ) ;
121
+ const versionPart = contents . match ( / ^ v e r s i o n = ( \d + ) \n / ) ;
122
+ if ( versionPart && versionPart [ 1 ] == cache . version )
123
+ cache . tabbar . contents = contents . replace ( / ^ v e r s i o n = ( \d + ) \n / , '' ) ;
124
+ }
116
125
cachedSignature = cache && cache . signature ;
117
126
log ( `getEffectiveWindowCache: got from the owner ` , mLastWindowCacheOwner , {
118
127
cachedSignature, cache, tabsDirty, collapsedDirty
@@ -449,6 +458,7 @@ async function updateWindowCache(key, value) {
449
458
function clearWindowCache ( ) {
450
459
log ( 'clearWindowCache ' , { stack : configs . debug && new Error ( ) . stack } ) ;
451
460
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR ) ;
461
+ updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ) ;
452
462
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_TABS_DIRTY ) ;
453
463
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR_COLLAPSED_DIRTY ) ;
454
464
}
@@ -526,13 +536,16 @@ async function updateCachedTabbar() {
526
536
updateWindowCache ( Constants . kWINDOW_STATE_CACHED_SIDEBAR , {
527
537
version : kCONTENTS_VERSION ,
528
538
tabbar : {
529
- contents : SidebarTabs . wholeContainer . innerHTML ,
530
539
style : mTabBar . getAttribute ( 'style' ) ,
531
540
pinnedTabsCount : Tab . getPinnedTabs ( mTargetWindow ) . length
532
541
} ,
533
542
indent : Indent . getCacheInfo ( ) ,
534
543
signature
535
544
} ) ;
545
+ updateWindowCache (
546
+ Constants . kWINDOW_STATE_CACHED_SIDEBAR_CONTENTS ,
547
+ new Blob ( [ `version=${ kCONTENTS_VERSION } \n${ SidebarTabs . wholeContainer . innerHTML } ` ] )
548
+ ) ;
536
549
}
537
550
538
551
0 commit comments