Skip to content

Commit 10575c8

Browse files
committed
fixed first snapshot not sending
1 parent 4d891c5 commit 10575c8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/extension/background.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// store ports in an array
22
const portsArr = [];
33
const reloaded = {};
4+
const firstSnapshotReceived = {};
45
const tabsObj = {};
56

67
function createTabObj(title) {
@@ -12,7 +13,6 @@ function createTabObj(title) {
1213
locked: false,
1314
paused: false,
1415
},
15-
firstSnapshot: true,
1616
};
1717
}
1818

@@ -117,8 +117,10 @@ chrome.runtime.onMessage.addListener((request, sender) => {
117117
const sourceTab = tabId;
118118

119119
// 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+
122124
tabsObj[tabId].snapshots.push(request.payload);
123125
if (portsArr.length > 0) {
124126
portsArr.forEach(bg => bg.postMessage({
@@ -161,4 +163,6 @@ chrome.tabs.onRemoved.addListener(tabId => {
161163

162164
// delete the tab from the tabsObj
163165
delete tabsObj[tabId];
166+
delete reloaded[tabId];
167+
delete firstSnapshotReceived[tabId];
164168
});

0 commit comments

Comments
 (0)