Skip to content

Commit 2c8fd5f

Browse files
committed
refactored code to remove console logs and fixed bugs
1 parent 6024b8f commit 2c8fd5f

File tree

3 files changed

+13
-55
lines changed

3 files changed

+13
-55
lines changed

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ const StateRoute = (props: StateRouteProps) => {
130130
// eslint-disable-next-line react/prop-types
131131
const maxHeight: number = 1200;
132132
const h = Math.min(height, maxHeight);
133-
console.log('h: ', h);
134133
return (
135134
<div>
136-
<input type="radio" value='enable' checked={selectedValue === 'enable'} /> <label htmlFor='enable'>Enable</label>
135+
<input type="radio" value='enable' checked={selectedValue === 'enable'} onChange={() => {
136+
enableAxTreeButton(); }} /> <label htmlFor='enable'>Enable</label>
137137
<input type="radio" value='disable' checked={selectedValue === 'disable'} onChange={() => {
138138
disableAxTree(); }}/>
139139
<label htmlFor='disable'>Disable</label>
@@ -248,7 +248,6 @@ const StateRoute = (props: StateRouteProps) => {
248248
// eslint-disable-next-line react/prop-types
249249
const maxHeight: number = 1200;
250250
const h = Math.min(height, maxHeight);
251-
console.log('h component map: ', h);
252251
return (
253252
<ComponentMap
254253
currentSnapshot={currLocation.stateSnapshot}

src/app/containers/MainContainer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function MainContainer(): JSX.Element {
3232
const { connectionStatus }: MainState = useSelector((state: RootState) => state.main);
3333

3434
// JR 12.22.23: so far this log always returns true
35-
//console.log('MainContainer connectionStatus at initialization: ', connectionStatus);
35+
// console.log('MainContainer connectionStatus at initialization: ', connectionStatus);
3636

3737
const [actionView, setActionView] = useState(true); // We create a local state 'actionView' and set it to true
3838

@@ -163,8 +163,6 @@ function MainContainer(): JSX.Element {
163163

164164
// }, 5000);
165165

166-
console.log(tabs[currentTab]);
167-
168166
const { axSnapshots, currLocation, viewIndex, sliderIndex, snapshots, hierarchy, webMetrics } =
169167
tabs[currentTab]; // we destructure the currentTab object which is passed in from background.js
170168
//@ts-ignore

src/extension/background.js

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ const pruneAxTree = (axTree) => {
3535

3636
if (!name) {
3737
if (ignored) {
38-
name = { value: `ignored node: ${ignoredReasons[0].name}` };
38+
// name = { value: 'ignored node'};
39+
if (ignoredReasons.length) {
40+
name = { value: `ignored node: ${ignoredReasons[0].name}` };
41+
}
42+
else {
43+
name = { value: 'ignored node'};
44+
}
3945
} else {
4046
name = { value: 'visible node with no name' };
4147
}
@@ -59,7 +65,6 @@ const pruneAxTree = (axTree) => {
5965
axArr.push(axNode);
6066
}
6167
}
62-
console.log('axArr: ', axArr);
6368
return axArr;
6469
};
6570

@@ -113,21 +118,13 @@ async function axRecord(tabId) {
113118
}
114119

115120
async function replaceEmptySnap(tabsObj, tabId, toggleAxRecord) {
116-
console.log(
117-
'background.js: top of replaceEmptySnap: tabsObj[tabId]:',
118-
JSON.parse(JSON.stringify(tabsObj[tabId])),
119-
);
120121
if (tabsObj[tabId].currLocation.axSnapshot === 'emptyAxSnap' && toggleAxRecord === true) {
121122
// add new ax snapshot to currlocation
122123
const addedAxSnap = await axRecord(tabId);
123124
tabsObj[tabId].currLocation.axSnapshot = addedAxSnap;
124125
// modify array to include the new recorded ax snapshot
125126
tabsObj[tabId].axSnapshots[tabsObj[tabId].currLocation.index] = addedAxSnap;
126127
}
127-
console.log(
128-
'background.js: bottom of replaceEmptySnap: tabsObj[tabId]:',
129-
JSON.parse(JSON.stringify(tabsObj[tabId])),
130-
);
131128
}
132129

133130
// This function will create the first instance of the test app's tabs object
@@ -366,10 +363,7 @@ chrome.runtime.onConnect.addListener((port) => {
366363
tabsObj[tabId].index = 1; //reset index
367364
tabsObj[tabId].currParent = 0; // reset currParent
368365
tabsObj[tabId].currBranch = 1; // reset currBranch
369-
console.log(
370-
'background.js: bottom of emptySnap: tabsObj[tabId]:',
371-
JSON.parse(JSON.stringify(tabsObj[tabId])),
372-
);
366+
373367
return true; // return true so that port remains open
374368

375369
case 'setPause': // Pause = lock on tab
@@ -405,8 +399,6 @@ chrome.runtime.onConnect.addListener((port) => {
405399
tabId,
406400
}),
407401
);
408-
} else {
409-
console.log('background.js: portsArr.length < 0');
410402
}
411403
return true; // return true so that port remains open
412404

@@ -460,21 +452,12 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
460452
break;
461453
}
462454
case 'jumpToSnap': {
463-
console.log(
464-
'background.js: top of jumpToSnap: tabsObj[tabId]:',
465-
JSON.parse(JSON.stringify(tabsObj[tabId])),
466-
);
467455
changeCurrLocation(tabsObj[tabId], tabsObj[tabId].hierarchy, index, name);
468456
// hack to test without message from mainSlice
469457
// toggleAxRecord = true;
470458
// record ax tree snapshot of the state that has now been jumped to if user did not toggle button on
471459
await replaceEmptySnap(tabsObj, tabId, toggleAxRecord);
472460

473-
console.log(
474-
'background.js: bottom of jumpToSnap: tabsObj[tabId]:',
475-
JSON.parse(JSON.stringify(tabsObj[tabId])),
476-
);
477-
478461
// sends new tabs obj to devtools
479462
if (portsArr.length > 0) {
480463
portsArr.forEach((bg) =>
@@ -484,9 +467,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
484467
tabId,
485468
}),
486469
);
487-
} else {
488-
console.log('background.js: portsArr.length < 0');
489-
}
470+
}
490471

491472
if (portsArr.length > 0) {
492473
portsArr.forEach((bg) =>
@@ -543,13 +524,6 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
543524
break;
544525
}
545526
case 'recordSnap': {
546-
console.log(
547-
'background.js: top of recordSnap: tabsObj[tabId]:',
548-
JSON.parse(JSON.stringify(tabsObj[tabId])),
549-
);
550-
551-
console.log('background.js: recordSnap case: toggleAxRecord:', toggleAxRecord);
552-
553527
const sourceTab = tabId;
554528
tabsObj[tabId].webMetrics = metrics;
555529

@@ -572,10 +546,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
572546
tabsObj[tabId],
573547
new HistoryNode(tabsObj[tabId], request.payload, addedAxSnap),
574548
);
575-
console.log(
576-
'background.js: bottom of recordSnap: tabsObj[tabId]:',
577-
JSON.parse(JSON.stringify(tabsObj[tabId])),
578-
);
549+
579550
if (portsArr.length > 0) {
580551
portsArr.forEach((bg) =>
581552
bg.postMessage({
@@ -595,13 +566,11 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
595566
tabsObj[tabId]?.currLocation?.stateSnapshot?.children[0]?.componentData?.actualDuration;
596567
const incomingSnap = request.payload.children[0].componentData.actualDuration;
597568
if (previousSnap === incomingSnap) {
598-
console.log('background.js: previousSnap===incomingSnap');
599569
break;
600570
}
601571

602572
// Or if it is a snapShot after a jump, we don't record it.
603573
if (reloaded[tabId]) {
604-
console.log('background.js: reloaded[tabId]');
605574
// don't add anything to snapshot storage if tab is reloaded for the initial snapshot
606575
reloaded[tabId] = false;
607576
} else {
@@ -622,12 +591,6 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
622591
tabsObj[tabId],
623592
new HistoryNode(tabsObj[tabId], request.payload, addedAxSnap),
624593
);
625-
console.log(
626-
'background.js: bottom of recordSnap: tabsObj[tabId]:',
627-
JSON.parse(JSON.stringify(tabsObj[tabId])),
628-
);
629-
} else {
630-
console.log('background.js: tabsObj[tabId][index]');
631594
}
632595
}
633596

@@ -640,8 +603,6 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
640603
sourceTab,
641604
}),
642605
);
643-
} else {
644-
console.log('background.js: portsArr.length < 0');
645606
}
646607
break;
647608
}

0 commit comments

Comments
 (0)