Skip to content

Commit f9ef014

Browse files
committed
Enhance messaging structure in Chrome extension background
- Added `windowId` to the data sent in the `QueryRequest` message for improved context. - Removed unnecessary console log from `getActiveTabForFocusedWindow` function to clean up the code. - Removed the listener for `onBoundsChanged` in the window event management to streamline event handling.
1 parent eb00af7 commit f9ef014

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

chrome-extension/src/background/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const listenMessageForUI = (
7070
case 'QueryRequest': {
7171
const { source, logic, url, nodeName, priority, tick } = message.body;
7272
const tabId = sender.tab?.id;
73+
const windowId = sender.tab?.windowId;
7374
const v = waitingQuery[source];
7475
if (v === undefined) {
7576
waitingQuery[source] = { resolves: [sendResponse] };
@@ -80,7 +81,7 @@ const listenMessageForUI = (
8081
v.resolves.push(sendResponse);
8182
}
8283
}
83-
const data = { source, logic, url, tabId, nodeName, priority, tick };
84+
const data = { source, logic, url, tabId, nodeName, priority, tick, windowId };
8485
ws?.send(JSON.stringify(data));
8586
return true;
8687
}

chrome-extension/src/background/tabs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const getAllTabs = async (): Promise<chrome.tabs.Tab[]> => {
2828
const all = () => {
2929
getActiveTabForFocusedWindow().then(tab => {
3030
if (tab == null) {
31-
console.log('getActiveTabForFocusedWindow', tab);
3231
return;
3332
}
3433
const id = tab.id;

chrome-extension/src/background/windows.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const stopListenWindows = () => {
7979
chrome.windows.onCreated.removeListener(_onCreated);
8080
chrome.windows.onRemoved.removeListener(_onRemoved);
8181
chrome.windows.onFocusChanged.removeListener(_onFocusChanged);
82-
chrome.windows.onBoundsChanged.removeListener(_onBoundsChanged);
8382
};
8483

8584
export const startListenWindows = () => {
@@ -88,5 +87,4 @@ export const startListenWindows = () => {
8887
chrome.windows.onCreated.addListener(_onCreated);
8988
chrome.windows.onRemoved.addListener(_onRemoved);
9089
chrome.windows.onFocusChanged.addListener(_onFocusChanged);
91-
chrome.windows.onBoundsChanged.addListener(_onBoundsChanged);
9290
};

0 commit comments

Comments
 (0)