From 493b81875a527b26acb9c276e11a395364d39ba9 Mon Sep 17 00:00:00 2001 From: yuygfgg <140488233+yuygfgg@users.noreply.github.com> Date: Sun, 14 Jul 2024 20:46:04 +0800 Subject: [PATCH 1/2] fix blank screen when reopening window on macos --- src/main/main.ts | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 5a6f793f4..ea3c7b720 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -67,8 +67,8 @@ if (store.get('ignore_ssl')) { // From https://github.com/tutao/tutanota/commit/92c6ed27625fcf367f0fbcc755d83d7ff8fde94b if (isLinux() && !process.argv.some((a) => a.startsWith('--password-store='))) { - const paswordStore = store.get('password_store', 'gnome-libsecret') as string; - app.commandLine.appendSwitch('password-store', paswordStore); + const passwordStore = store.get('password_store', 'gnome-libsecret') as string; + app.commandLine.appendSwitch('password-store', passwordStore); } let mainWindow: BrowserWindow | null = null; @@ -210,7 +210,7 @@ const createTray = () => { const createWindow = async (first = true) => { if (isDevelopment) { - await installExtensions(); + await installExtensions().catch(console.log); } const nativeFrame = store.get('window_window_bar_style') === 'linux'; @@ -258,7 +258,6 @@ const createWindow = async (first = true) => { ...(nativeFrame && isWindows() && nativeFrameConfig.windows), }); - // From https://github.com/electron/electron/issues/526#issuecomment-1663959513 const bounds = store.get('bounds') as Rectangle | undefined; if (bounds) { const screenArea = screen.getDisplayMatching(bounds).workArea; @@ -312,7 +311,6 @@ const createWindow = async (first = true) => { }); ipcMain.on('app-restart', () => { - // Fix for .AppImage if (process.env.APPIMAGE) { app.exit(); app.relaunch({ @@ -364,20 +362,6 @@ const createWindow = async (first = true) => { } }); - ipcMain.handle('open-item', async (_event, path: string) => { - return new Promise((resolve, reject) => { - access(path, constants.F_OK, (error) => { - if (error) { - reject(error); - return; - } - - shell.showItemInFolder(path); - resolve(); - }); - }); - }); - const globalMediaKeysEnabled = store.get('global_media_hotkeys', true) as boolean; if (globalMediaKeysEnabled) { @@ -487,7 +471,7 @@ const createWindow = async (first = true) => { const menuBuilder = new MenuBuilder(mainWindow); menuBuilder.buildMenu(); - // Open urls in the user's browser + // Open URLs in the user's browser mainWindow.webContents.setWindowOpenHandler((edata) => { shell.openExternal(edata.url); return { action: 'deny' }; @@ -670,3 +654,20 @@ if (!singleInstance) { }) .catch(console.log); } + +// Register 'open-item' handler globally, ensuring it is only registered once +if (!ipcMain.eventNames().includes('open-item')) { + ipcMain.handle('open-item', async (_event, path: string) => { + return new Promise((resolve, reject) => { + access(path, constants.F_OK, (error) => { + if (error) { + reject(error); + return; + } + + shell.showItemInFolder(path); + resolve(); + }); + }); + }); +} From 0113ef2582ebd0bb0274203ef6a878a77465518f Mon Sep 17 00:00:00 2001 From: yuygfgg <140488233+yuygfgg@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:15:58 +0800 Subject: [PATCH 2/2] restore comments --- src/main/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/main.ts b/src/main/main.ts index ea3c7b720..6c3a2cef4 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -258,6 +258,7 @@ const createWindow = async (first = true) => { ...(nativeFrame && isWindows() && nativeFrameConfig.windows), }); + // From https://github.com/electron/electron/issues/526#issuecomment-1663959513 const bounds = store.get('bounds') as Rectangle | undefined; if (bounds) { const screenArea = screen.getDisplayMatching(bounds).workArea; @@ -311,6 +312,7 @@ const createWindow = async (first = true) => { }); ipcMain.on('app-restart', () => { + // Fix for .AppImage if (process.env.APPIMAGE) { app.exit(); app.relaunch({