File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
// store ports in an array
2
2
const portsArr = [ ] ;
3
3
const reloaded = { } ;
4
+ const firstSnapshotReceived = { } ;
4
5
const tabsObj = { } ;
5
6
6
7
function createTabObj ( title ) {
@@ -12,7 +13,6 @@ function createTabObj(title) {
12
13
locked : false ,
13
14
paused : false ,
14
15
} ,
15
- firstSnapshot : true ,
16
16
} ;
17
17
}
18
18
@@ -117,8 +117,10 @@ chrome.runtime.onMessage.addListener((request, sender) => {
117
117
const sourceTab = tabId ;
118
118
119
119
// first snapshot received from tab
120
- if ( tabsObj [ tabId ] . firstSnapshot ) {
121
- tabsObj [ tabId ] . firstSnapshot = false ;
120
+ if ( ! firstSnapshotReceived [ tabId ] ) {
121
+ firstSnapshotReceived [ tabId ] = true ;
122
+ reloaded [ tabId ] = false ;
123
+
122
124
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
123
125
if ( portsArr . length > 0 ) {
124
126
portsArr . forEach ( bg => bg . postMessage ( {
@@ -161,4 +163,6 @@ chrome.tabs.onRemoved.addListener(tabId => {
161
163
162
164
// delete the tab from the tabsObj
163
165
delete tabsObj [ tabId ] ;
166
+ delete reloaded [ tabId ] ;
167
+ delete firstSnapshotReceived [ tabId ] ;
164
168
} ) ;
You can’t perform that action at this time.
0 commit comments