Skip to content

Commit be0cce9

Browse files
committed
tons more console logs. Updated the SwitchApp.tsx to have a label for the toggleRecord button.
1 parent e97830b commit be0cce9

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

src/app/components/SwitchApp.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { setTab } from '../slices/mainSlice';
44
//importing these methods for RTK
55
import { useSelector, useDispatch } from 'react-redux';
66
import { MainState, RootState } from '../FrontendTypes';
7+
import { current } from '@reduxjs/toolkit';
78

89
/*
910
This is the dropdown menu on the left column above the 'clear' button and the state snapshots list. It allows us to switch between which website/application we are currently working on.
@@ -17,7 +18,7 @@ const SwitchAppDropdown = (): JSX.Element => {
1718
const { currentTab, tabs }: MainState = useSelector((state: RootState) => state.main);
1819

1920
const tabsArray: {}[] = []; // tabsArray is an empty array that will take objects as it's elements
20-
21+
console.log('switchAppDropdown; currentTab: ', currentTab, 'tabs: ', tabs);
2122
Object.keys(tabs).forEach((tab) => {
2223
// We populate our 'tabsArray' with objects derived from the 'tab' that is currently being iterated on.
2324
tabsArray.unshift({ value: tab, label: tabs[tab].title });
@@ -45,8 +46,12 @@ const SwitchAppDropdown = (): JSX.Element => {
4546
classNamePrefix='tab-select'
4647
value={currTab}
4748
styles={customStyles}
48-
onChange={(e): void => {
49-
dispatch(setTab(parseInt(e.value, 10)));
49+
onInputChange={(inputValue, { action }): void => {
50+
console.log('onInputChange action', action);
51+
if (action === 'set-value') {
52+
console.log('Option selected: ', inputValue);
53+
// dispatch(setTab(parseInt(e.value, 10)));
54+
}
5055
}}
5156
options={tabsArray}
5257
/>

src/app/containers/ActionContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function ActionContainer(props: ActionContainerProps): JSX.Element {
187187
</aside>
188188
</div>
189189
<a type='button' id='recordBtn' onClick={toggleRecord}>
190-
<i />
190+
<div style={{ display: 'flex', alignItems: 'center' }}>Toggle Record</div>
191191
{recordingActions ? <Switch defaultChecked /> : <Switch />}
192192
</a>
193193
</div>

src/app/containers/MainContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function MainContainer(): JSX.Element {
7979
break;
8080
}
8181
case 'changeTab': {
82+
console.log('made it to the mainContainer dispatch');
8283
dispatch(setTab(payload));
8384
break;
8485
}
@@ -106,9 +107,12 @@ function MainContainer(): JSX.Element {
106107
// Connect ot port and assign evaluated result (obj) to currentPort
107108
const currentPort = chrome.runtime.connect();
108109

110+
// JR: why are we removing the listener just to readd it? logging here
111+
console.log('messageListener before removing: ', messageListener);
109112
// If messageListener exists on currentPort, remove it
110113
while (currentPort.onMessage.hasListener(messageListener))
111114
currentPort.onMessage.removeListener(messageListener);
115+
console.log('messageListener after removing: ', messageListener);
112116

113117
// Add messageListener to the currentPort
114118
currentPort.onMessage.addListener(messageListener);

src/app/slices/mainSlice.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,15 @@ export const mainSlice = createSlice({
127127
setTab: (state, action) => {
128128
const { tabs, currentTab } = state;
129129
const { mode } = tabs[currentTab] || {};
130-
130+
console.log('mainSlice. mode: ', mode, 'payload: ', action.payload);
131131
if (!mode?.paused) {
132132
if (typeof action.payload === 'number') {
133133
state.currentTab = action.payload;
134134
return;
135135
} else if (typeof action.payload === 'object') {
136136
state.currentTab = action.payload.tabId;
137137
if (action.payload?.title) state.currentTitle = action.payload.title;
138+
console.log('mainSlice setTab currentTitle: ', state.currentTitle);
138139
return;
139140
}
140141
}

src/extension/background.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ function changeCurrLocation(tabObj, rootNode, index, name) {
137137
This allows us to set up listener's for when we connect, message, and disconnect the script.
138138
*/
139139

140+
// FROM FRONTEND CONNECTION TO BACKGROUND
140141
// Establishing incoming connection with Reactime.
141142
chrome.runtime.onConnect.addListener((port) => {
142143
/*
@@ -158,9 +159,10 @@ chrome.runtime.onConnect.addListener((port) => {
158159
159160
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.
160161
*/
161-
162+
console.log('tabsObj onConnect: ', tabsObj);
162163
portsArr.push(port); // push each Reactime communication channel object to the portsArr
163-
164+
console.log('portsArr onConnect: ', portsArr);
165+
// JR: CONSIDER DELETING
164166
if (portsArr.length > 0) {
165167
portsArr.forEach((bg) => {
166168
// go through each port object (each Reactime instance)
@@ -172,6 +174,7 @@ chrome.runtime.onConnect.addListener((port) => {
172174
});
173175
}
174176

177+
// JR: CONSIDER DELETING
175178
if (Object.keys(tabsObj).length > 0) {
176179
port.postMessage({
177180
action: 'initialConnectSnapshots',
@@ -191,6 +194,7 @@ chrome.runtime.onConnect.addListener((port) => {
191194
}
192195
});
193196

197+
// FROM FRONTEND TO BACKGROUND
194198
// listen for message containing a snapshot from devtools and send it to contentScript -
195199
// (i.e. they're all related to the button actions on Reactime)
196200
port.onMessage.addListener((msg) => {
@@ -261,9 +265,10 @@ chrome.runtime.onConnect.addListener((port) => {
261265
});
262266
});
263267

268+
// FROM CONTENT SCRIPT TO BACKGROUND
264269
// background.js listening for a message from contentScript.js
265270
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
266-
console.log('background.js received message with action: ', request.action);
271+
console.log('background.js received message with action: ', request.action, request);
267272
// AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED: set Content
268273
if (request.type === 'SIGN_CONNECT') {
269274
return true;
@@ -460,6 +465,7 @@ chrome.tabs.onActivated.addListener((info) => {
460465
// never set a reactime instance to the active tab
461466
if (!tab.pendingUrl?.match('^chrome-extension')) {
462467
activeTab = tab;
468+
console.log('tabs.onActivated info: ', info);
463469
console.log('activeTab: ', activeTab);
464470
if (portsArr.length > 0) {
465471
portsArr.forEach((bg) =>

0 commit comments

Comments
 (0)