Skip to content

Commit 6e8e9b4

Browse files
Christopher StamperChristopher Stamper
authored andcommitted
Removed unused code, comments, and console logs
1 parent cc110fc commit 6e8e9b4

File tree

4 files changed

+14
-35
lines changed

4 files changed

+14
-35
lines changed

src/app/containers/ButtonsContainer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ function ButtonsContainer(): JSX.Element {
5454
// const [{ tabs, currentTab, currentTabInApp }, dispatch] = useStoreContext();
5555
// const [state, dispatch] = useStoreContext();
5656
const dispatch = useDispatch();
57-
const currentTab = useSelector((state: any) => state.main.currentTab);
58-
const tabs = useSelector((state: any)=>state.main.tabs);
59-
const currentTabInApp = useSelector((state: any)=> state.main.currentTabInApp);
60-
const {connectionStatus, hasInitialized} = useSelector((state: any)=> state.main);
57+
const {currentTab, tabs, currentTabInApp, connectionStatus} = useSelector((state: any)=> state.main);
6158
const { mode: { paused }} = tabs[currentTab];
59+
6260
//adding a local state using useState for the reconnect button functionality
6361
const [reconnectDialogOpen, setReconnectDialogOpen] = useState(false);
6462
const [disconnectedDialogOpen, setDisconnectedDialogOpen] = useState(false);
@@ -71,7 +69,6 @@ function ButtonsContainer(): JSX.Element {
7169
const handleReconnectConfirm = () => {
7270
//reconnection logic here
7371
dispatch(startReconnect());
74-
// reconnectDialogOpen ? setReconnectDialogOpen(false) : setDisconnectedDialogOpen(false);
7572
handleReconnectCancel();
7673
}
7774

src/app/containers/MainContainer.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
noDev,
1515
setCurrentLocation,
1616
disconnected,
17-
endReconnect,
18-
pause,
17+
endReconnect
1918
} from '../RTKslices';
2019
import { useDispatch, useSelector } from 'react-redux';
2120
//importing mainContainerslice
@@ -59,18 +58,16 @@ function MainContainer(): JSX.Element {
5958

6059
const handleDisconnect = (msg): void => {
6160
if (msg === 'portDisconnect') {
62-
console.log('unexpected port disconnect: ', msg);
61+
console.log('unexpected port disconnection');
6362
dispatch(disconnected());
6463
}
6564
}
6665

6766
useEffect(() => {
68-
console.log('LOL: ', port);
6967
if (port) return; // only open port once so if it exists, do not run useEffect again
70-
console.log('Okie')
68+
7169
// chrome.runtime allows our application to retrieve our service worker (our eventual bundles/background.bundle.js after running npm run build), details about the manifest, and allows us to listen and respond to events in our application lifecycle.
7270
const currentPort = chrome.runtime.connect(); // we connect to our service worker
73-
console.log('currentPort', currentPort);
7471

7572
// listen for a message containing snapshots from the /extension/build/background.js service worker
7673
currentPort.onMessage.addListener(
@@ -119,24 +116,22 @@ function MainContainer(): JSX.Element {
119116
}
120117
default:
121118
}
122-
// return true; // we return true so that the connection stays open, otherwise the message channel will close
123119
},
124120
);
125121

126122

127123
if (chrome.runtime.onMessage.hasListener(handleDisconnect))
128-
chrome.runtime.onMessage.removeListener(handleDisconnect);
124+
chrome.runtime.onMessage.removeListener(handleDisconnect);
129125

130126
// used to track when the above connection closes unexpectedly. Remember that it should persist throughout the application lifecycle
131127
chrome.runtime.onMessage.addListener(handleDisconnect);
132128

133-
// setTimeout(() => {
134-
// console.log('disconnecting')
135-
// currentPort.disconnect();
136-
// }, 30000);
129+
// assign port to state so it could be used by other components
130+
if (currentPort)
131+
dispatch(setPort(currentPort));
137132

138-
if (currentPort) dispatch(setPort(currentPort)); // assign port to state so it could be used by other components
139-
if (!connectionStatus && reconnectRequested) dispatch(endReconnect());
133+
if (!connectionStatus && reconnectRequested)
134+
dispatch(endReconnect());
140135
});
141136

142137
// Error Page launch IF(Content script not launched OR RDT not installed OR Target not React app)

src/extension/background.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,10 @@ chrome.runtime.onConnect.addListener((port) => {
159159
Again, this port object is used for communication within your extension, not for communication with external ports or tabs in the Chrome browser. If you need to interact with specific tabs or external ports, you would use other APIs or methods, such as chrome.tabs or other Chrome Extension APIs.
160160
*/
161161

162-
console.log('ATTEMPTING CONNECTION');
163162
portsArr.push(port); // push each Reactime communication channel object to the portsArr
164-
console.log('portsArr: ', portsArr);
165-
163+
166164
// On Reactime launch: make sure RT's active tab is correct
167165
if (portsArr.length > 0) {
168-
console.log('yo');
169-
console.log('activeTab: ', activeTab)
170166
portsArr.forEach((bg) => {// go through each port object (each Reactime instance)
171167
bg.postMessage({ // send passed in action object as a message to the current port
172168
action: 'changeTab',
@@ -177,7 +173,6 @@ chrome.runtime.onConnect.addListener((port) => {
177173

178174
// send tabs obj to the connected devtools as soon as connection to devtools is made
179175
if (Object.keys(tabsObj).length > 0) {
180-
console.log('yuh');
181176
port.postMessage({
182177
action: 'initialConnectSnapshots',
183178
payload: tabsObj,
@@ -186,7 +181,7 @@ chrome.runtime.onConnect.addListener((port) => {
186181

187182
// every time devtool is closed, remove the port from portsArr
188183
port.onDisconnect.addListener((e) => {
189-
console.log('PORT DISCONNECTED BACKGROUND');
184+
console.log('PORT DISCONNECTED');
190185
for (let i = 0; i < portsArr.length; i += 1) {
191186
if (portsArr[i] === e) {
192187
portsArr.splice(i, 1);
@@ -199,7 +194,6 @@ chrome.runtime.onConnect.addListener((port) => {
199194
// listen for message containing a snapshot from devtools and send it to contentScript -
200195
// (i.e. they're all related to the button actions on Reactime)
201196
port.onMessage.addListener((msg) => {
202-
console.log('pls: ', msg);
203197
// msg is action denoting a time jump in devtools
204198
// ---------------------------------------------------------------
205199
// message incoming from devTools should look like this:

src/extension/contentScript.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ window.addEventListener('message', (msg) => {
1919
// One-time request tells the background script that the tab has reloaded.
2020
chrome.runtime.sendMessage({ action: 'tabReload' });
2121
firstMessage = false;
22-
// const keepAliveContentScript = setInterval(() => { // interval to keep connection to service worker connection alive
23-
// chrome.runtime.sendMessage({
24-
// action: 'keepAlive' // messages sent to port to keep connection alive
25-
// })
26-
// }, 295000) // messages must happen within five minutes
2722
}
2823

2924
// After tabs object has been created from firstMessage, backend (linkFiber.ts)
@@ -57,11 +52,9 @@ chrome.runtime.onMessage.addListener((request) => {
5752
}
5853
// After the jumpToSnap action has been sent back to background js,
5954
// it will send the same action to backend files (index.ts) for it execute the jump feature
60-
if (action === 'portDisconnect') console.log('RECEIVED PORT DISCONNECT MESSAGE contentScript')
6155
// '*' == target window origin required for event to be dispatched, '*' = no preference
62-
// window.postMessage(request, '*');
56+
window.postMessage(request, '*');
6357
}
64-
// return true; // attempt to fix port closing console error
6558
});
6659

6760

0 commit comments

Comments
 (0)