Skip to content

Commit 6c1c4e1

Browse files
committed
added comments about a potential bugfix in background.js (should also be implemented in mainslice
1 parent e55f799 commit 6c1c4e1

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/app/slices/mainSlice.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ export const mainSlice = createSlice({
4747
tabs[currentTab].playing = false;
4848

4949
const lastSnapshot = tabs[currentTab].snapshots[tabs[currentTab].snapshots.length - 1]; // the most recent snapshot
50+
const lastAxSnapshot = tabs[currentTab].axSnapshots[tabs[currentTab].axSnapshots.length - 1]; // the most recent snapshot
5051

5152
tabs[currentTab].hierarchy.stateSnapshot = { ...lastSnapshot }; // resets hierarchy to page last state recorded
53+
tabs[currentTab].hierarchy.axSnapshot = lastAxSnapshot; // resets hierarchy to page last state recorded
5254
tabs[currentTab].hierarchy.children = []; // resets hierarchy
5355
tabs[currentTab].snapshots = [lastSnapshot]; // resets snapshots to page last state recorded
56+
tabs[currentTab].axSnapshots = [lastAxSnapshot]; // resets snapshots to page last state recorded
5457

5558
// resets currLocation to page last state recorded
5659
tabs[currentTab].currLocation = tabs[currentTab].hierarchy;

src/extension/background.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ chrome.runtime.onConnect.addListener((port) => {
270270
// resets hierarchy to page last state recorded
271271
...tabsObj[tabId].snapshots[0],
272272
};
273-
tabsObj[tabId].axSnapshots = tabsObj[tabId].axSnapshots[0];
274-
tabsObj[tabId].hierarchy.axSnapshot = tabsObj[tabId].axSnapshots[0]; //what about other hierarchy properties? Shouldn't those be reset as well?
275-
// other hierarchy properties do not have to be set because you maintain the root history node
273+
tabsObj[tabId].axSnapshots = [
274+
tabsObj[tabId].axSnapshots[tabsObj[tabId].axSnapshots.length - 1],
275+
]; // resets axSnapshots to page last recorded
276+
tabsObj[tabId].hierarchy.axSnapshot = tabsObj[tabId].axSnapshots[0]; // resets hierarchy to page of last ax tree recorded
277+
// SHOULDN'T HIERARCHY.AXSNAPSHOT AND HIERARCHY.SNAPSHOT BE RESET BASED ON CURRLOCATION, NOT LAST SNAP RECORDED BECAUSE WHAT IF JUMPING TO PREVIOUS SNAPSHOT AND THEN CLEAR. WOULDN'T THAT REQUIRE UPDATING THE DEMO APP TO THE LAST STATE RECORDED AS WELL?
276278
tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy; // resets currLocation to page last state recorded
277279
tabsObj[tabId].index = 1; //reset index
278280
tabsObj[tabId].currParent = 0; // reset currParent
@@ -500,10 +502,14 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
500502
const previousSnap =
501503
tabsObj[tabId]?.currLocation?.stateSnapshot?.children[0]?.componentData?.actualDuration;
502504
const incomingSnap = request.payload.children[0].componentData.actualDuration;
503-
if (previousSnap === incomingSnap) break;
505+
if (previousSnap === incomingSnap) {
506+
console.log('background.js: previousSnap===incomingSnap');
507+
break;
508+
}
504509

505510
// Or if it is a snapShot after a jump, we don't record it.
506511
if (reloaded[tabId]) {
512+
console.log('background.js: reloaded[tabId]');
507513
// don't add anything to snapshot storage if tab is reloaded for the initial snapshot
508514
reloaded[tabId] = false;
509515
} else {
@@ -519,6 +525,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
519525
'background.js: bottom of recordSnap: tabsObj[tabId]:',
520526
JSON.parse(JSON.stringify(tabsObj[tabId])),
521527
);
528+
} else {
529+
console.log('background.js: tabsObj[tabId][index]');
522530
}
523531
}
524532

@@ -531,6 +539,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
531539
sourceTab,
532540
}),
533541
);
542+
} else {
543+
console.log('background.js: portsArr.length < 0');
534544
}
535545
break;
536546
}

0 commit comments

Comments
 (0)