Skip to content

Commit c391191

Browse files
committed
fixed clear button bug where pressing it multiple times would crash the app. Still some console.logs left in there tho
1 parent 2c14ad0 commit c391191

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/app/slices/mainSlice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ export const mainSlice = createSlice({
5151
const currAxSnapshot = tabs[currentTab].axSnapshots[tabs[currentTab].currLocation.index]; // current snapshot
5252

5353
tabs[currentTab].hierarchy.stateSnapshot = { ...currSnapshot }; // resets hierarchy to page current snapshot
54-
// not sure why shallow deep copy
55-
tabs[currentTab].hierarchy.axSnapshot = currAxSnapshot; // resets hierarchy to current snapshot
54+
tabs[currentTab].hierarchy.axSnapshot = { ...currAxSnapshot }; // resets hierarchy to current accessibility tree snapshot
5655
tabs[currentTab].hierarchy.children = []; // resets hierarchy
5756
tabs[currentTab].snapshots = [currSnapshot]; // resets snapshots to current snapshot
5857
tabs[currentTab].axSnapshots = [currAxSnapshot]; // resets snapshots to current snapshot
@@ -61,6 +60,7 @@ export const mainSlice = createSlice({
6160
tabs[currentTab].index = 1;
6261
tabs[currentTab].currParent = 0;
6362
tabs[currentTab].currBranch = 1;
63+
tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
6464
tabs[currentTab].seriesSavedStatus = false;
6565
},
6666

src/extension/background.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ chrome.runtime.onConnect.addListener((port) => {
358358

359359
// emptySnap actions comes through when the user uses the 'clear' button on the front end to clear the snapshot history and move slider back to 0 position
360360
case 'emptySnap':
361+
console.log(
362+
'background.js: top of emptySnap tabsObj[tabId]:',
363+
JSON.parse(JSON.stringify(tabsObj[tabId])),
364+
);
361365
tabsObj[tabId].snapshots = [tabsObj[tabId].snapshots[tabsObj[tabId].currLocation.index]]; // reset snapshots to current page state
362366
tabsObj[tabId].hierarchy.children = []; // resets hierarchy
363367
tabsObj[tabId].hierarchy.stateSnapshot = {
@@ -366,12 +370,23 @@ chrome.runtime.onConnect.addListener((port) => {
366370
...tabsObj[tabId].snapshots[0],
367371
};
368372
tabsObj[tabId].axSnapshots = [
369-
tabsObj[tabId].axSnapshots[tabsObj[tabId].currLocation.index],
373+
JSON.parse(JSON.stringify(tabsObj[tabId].axSnapshots[tabsObj[tabId].currLocation.index])),
370374
]; // resets axSnapshots to current page state
371-
tabsObj[tabId].hierarchy.axSnapshot = tabsObj[tabId].axSnapshots[0]; // resets hierarchy to ax tree of current page state
375+
console.log(
376+
'background.js: tabsObj[tabId].axSnapshots:',
377+
JSON.parse(JSON.stringify(tabsObj[tabId].axSnapshots)),
378+
);
379+
tabsObj[tabId].hierarchy.axSnapshot = JSON.parse(
380+
JSON.stringify(tabsObj[tabId].axSnapshots[0]),
381+
); // resets hierarchy to ax tree of current page state
372382
tabsObj[tabId].index = 1; //reset index
373383
tabsObj[tabId].currParent = 0; // reset currParent
374384
tabsObj[tabId].currBranch = 1; // reset currBranch
385+
tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy;
386+
console.log(
387+
'background.js: bottom of emptySnap tabsObj[tabId]:',
388+
JSON.parse(JSON.stringify(tabsObj[tabId])),
389+
);
375390

376391
return true; // return true so that port remains open
377392

0 commit comments

Comments
 (0)