[GH-2534] Refocus the popup window if already exists (#2581)

* [GH-2534] Refocus the popup window if already exists

* PR feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Devin Binnie
2023-03-06 11:49:15 -05:00
committed by GitHub
parent 20847ad5ab
commit 99a84a0fd7

View File

@@ -199,27 +199,26 @@ export class WebContentsEventManager {
}
});
this.popupWindow.webContents.setWindowOpenHandler(this.denyNewWindow);
this.popupWindow.once('ready-to-show', () => {
this.popupWindow!.show();
});
this.popupWindow.once('closed', () => {
this.popupWindow = undefined;
});
const contextMenu = new ContextMenu({}, this.popupWindow);
contextMenu.reload();
}
const popupWindow = this.popupWindow;
popupWindow.once('ready-to-show', () => popupWindow.show());
if (urlUtils.isManagedResource(serverURL, parsedURL)) {
this.popupWindow.loadURL(details.url);
popupWindow.loadURL(details.url);
} else {
// currently changing the userAgent for popup windows to allow plugins to go through google's oAuth
// should be removed once a proper oAuth2 implementation is setup.
this.popupWindow.loadURL(details.url, {
popupWindow.loadURL(details.url, {
userAgent: composeUserAgent(),
});
}
const contextMenu = new ContextMenu({}, this.popupWindow);
contextMenu.reload();
return {action: 'deny'};
}