Skip to content

Commit

Permalink
Merge pull request #668 from yuygfgg/patch-1
Browse files Browse the repository at this point in the history
fix blank screen when reopening window on macos
  • Loading branch information
jeffvli authored Jul 21, 2024
2 parents ed8e5e6 + 0113ef2 commit 3edc6ba
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -364,20 +364,6 @@ const createWindow = async (first = true) => {
}
});

ipcMain.handle('open-item', async (_event, path: string) => {
return new Promise<void>((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) {
Expand Down Expand Up @@ -487,7 +473,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' };
Expand Down Expand Up @@ -670,3 +656,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<void>((resolve, reject) => {
access(path, constants.F_OK, (error) => {
if (error) {
reject(error);
return;
}

shell.showItemInFolder(path);
resolve();
});
});
});
}

0 comments on commit 3edc6ba

Please sign in to comment.