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/MainContainer.tsx
+19-33Lines changed: 19 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -143,41 +143,27 @@ function MainContainer(): JSX.Element {
143
143
}
144
144
145
145
useEffect(()=>{
146
-
if(!connectRequested)return;// only open port once so if it exists, do not run useEffect again
147
-
148
-
// 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.
149
-
150
-
handleConnect()
151
-
.then((port: chrome.runtime.Port|null)=>{
152
-
if(port){
153
-
console.log('PORT SUCCESS: ',port)
146
+
if(port)return;// only open port once so if it exists, do not run useEffect again
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.
163
160
*/
164
-
165
-
console.log('Port: ',port);
166
-
portSuccessfullyConnected=port ? true : false;
167
161
168
162
portsArr.push(port);// push each Reactime communication channel object to the portsArr
169
163
170
-
port.onMessage.addListener((msg)=>{
171
-
console.log('background message: ',msg);
172
-
if(msg.initialized&&portsArr.length>0){
173
-
console.log('sending changeTab message!!!!');
174
-
portsArr.forEach((bg)=>{// go through each port object (each Reactime instance)
175
-
bg.postMessage({// send passed in action object as a message to the current port
0 commit comments