fix(electron): possible issue on openning two main windows (#6307)

fix https://github.com/toeverything/AFFiNE/issues/6303

fetching `getWindowAdditionalArguments` requires forking a new process & handshake, which could be time consuming
This commit is contained in:
pengx17
2024-03-26 03:29:37 +00:00
parent 2662ba763c
commit e9bc24bf37

View File

@@ -183,8 +183,10 @@ let hiddenMacWindow: BrowserWindow | undefined;
*/
export async function initAndShowMainWindow() {
if (!browserWindow || (await browserWindow.then(w => w.isDestroyed()))) {
const additionalArguments = await getWindowAdditionalArguments();
browserWindow = createWindow(additionalArguments);
browserWindow = (async () => {
const additionalArguments = await getWindowAdditionalArguments();
return createWindow(additionalArguments);
})();
}
const mainWindow = await browserWindow;