Skip to content

Commit 5e3dbec

Browse files
committed
fix(App): Don't open multiple windows of the same type
1 parent 4805775 commit 5e3dbec

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/electron/ipc-api/overlayWindow.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ export function openOverlay(mainWindow: BrowserWindow, settings: any, args: IArg
2323
try {
2424
debug('Got overlay window open request', args);
2525

26+
let { route } = args;
27+
if (eventSenderId) {
28+
route = route.replace('{webContentsId}', eventSenderId.toString());
29+
}
30+
31+
const windows = BrowserWindow.getAllWindows();
32+
const win = windows.find(window => window.webContents.getURL().endsWith(route));
33+
34+
if (win) {
35+
win.show();
36+
win.focus();
37+
38+
return resolve('show');
39+
}
40+
2641
const bounds = mainWindow.getBounds();
2742

2843
let parent = args.modal ? mainWindow : null;
@@ -58,11 +73,6 @@ export function openOverlay(mainWindow: BrowserWindow, settings: any, args: IArg
5873
}
5974
});
6075

61-
let { route } = args;
62-
if (eventSenderId) {
63-
route = route.replace('{webContentsId}', eventSenderId.toString());
64-
}
65-
6676
window.loadFile('overlay.html', {
6777
hash: route,
6878
query: args.query,

0 commit comments

Comments
 (0)