You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/containers/ErrorContainer.tsx
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -25,49 +25,56 @@ function ErrorContainer(): JSX.Element {
25
25
dispatch(launchContentScript(tabs[currentTab]));
26
26
}
27
27
28
-
conststatus={// We create a status object that we may use later if tabs[currentTab] exists
28
+
conststatus={
29
+
// We create a status object that we may use later if tabs[currentTab] exists
29
30
contentScriptLaunched: false,
30
31
reactDevToolsInstalled: false,
31
32
targetPageisaReactApp: false,
32
33
};
33
34
34
-
35
-
if(tabs[currentTab]){// If we do have a tabs[currentTab] object, we replace the status obj we declared above with the properties of the tabs[currentTab].status
35
+
if(tabs[currentTab]){
36
+
// If we do have a tabs[currentTab] object, we replace the status obj we declared above with the properties of the tabs[currentTab].status
36
37
Object.assign(status,tabs[currentTab].status);
37
38
}
38
39
39
40
// hook that sets timer while waiting for a snapshot from the background script, resets if the tab changes/reloads
40
41
useEffect(()=>{
41
-
// We declare a function
42
-
functionsetLoadingArray(i: number,value: boolean){// 'setLoadingArray' checks an element in our 'loadingArray' local state and compares it with passed in boolean argument. If they don't match, we update our local state replacing the selected element with the boolean argument
43
-
if(loadingArray[i]!==value){// this conditional helps us avoid unecessary state changes if the element and the value are already the same
// 'setLoadingArray' checks an element in our 'loadingArray' local state and compares it with passed in boolean argument. If they don't match, we update our local state replacing the selected element with the boolean argument
45
+
if(loadingArray[i]!==value){
46
+
// this conditional helps us avoid unecessary state changes if the element and the value are already the same
44
47
constloadingArrayClone=[...loadingArray];
45
48
loadingArrayClone[i]=value;
46
49
setLoading(loadingArrayClone);
47
50
}
48
51
}
49
52
50
-
if(titleTracker.current!==currentTitle){// if the current tab changes/reloads, we reset loadingArray to it's default [true, true, true]
53
+
if(titleTracker.current!==currentTitle){
54
+
// if the current tab changes/reloads, we reset loadingArray to it's default [true, true, true]
51
55
titleTracker.current=currentTitle;
52
56
setLoadingArray(0,true);
53
57
setLoadingArray(1,true);
54
58
setLoadingArray(2,true);
55
59
56
-
if(timeout.current){// if there is a current timeout set, we clear it
60
+
if(timeout.current){
61
+
// if there is a current timeout set, we clear it
57
62
clearTimeout(timeout.current);
58
63
timeout.current=null;
59
64
}
60
65
}
61
66
62
-
if(!status.contentScriptLaunched){// if content script hasnt been launched/found, set a timer or immediately update 'loadingArray' state
67
+
if(!status.contentScriptLaunched){
68
+
// if content script hasnt been launched/found, set a timer or immediately update 'loadingArray' state
63
69
64
-
if(loadingArray[0]===true){// if loadingArray[0] is true, then that means our timeout.current is still null so we now set it to a setTimeout function that will flip loadingArray[0] to false after 3 seconds
70
+
if(loadingArray[0]===true){
71
+
// if loadingArray[0] is true, then that means our timeout.current is still null so we now set it to a setTimeout function that will flip loadingArray[0] to false after 3 seconds
65
72
timeout.current=setTimeout(()=>{
66
73
setLoadingArray(0,false);
67
74
},3000);// increased from 1500
68
75
}
69
76
}else{
70
-
setLoadingArray(0,false)// if status.contentScriptLaunched is true, that means timeout.current !== null. This means that useEffect was triggered previously.
77
+
setLoadingArray(0,false);// if status.contentScriptLaunched is true, that means timeout.current !== null. This means that useEffect was triggered previously.
71
78
}
72
79
73
80
// The next two if statements are written in a way to allow the checking of 'content script hook', 'reactDevTools check', and 'target page is a react app' to be run in chronological order.
@@ -86,7 +93,7 @@ function ErrorContainer(): JSX.Element {
0 commit comments