Skip to content

Commit

Permalink
Use async app picker in IPC API to avoid UI freeze
Browse files Browse the repository at this point in the history
Without this, the rest of the UI visually freezes (boxes repeating if
the dialog is dragged around) while the file selector is open.
  • Loading branch information
pimterry committed Jul 5, 2024
1 parent 6e374a0 commit 9939f1a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,16 @@ const ipcHandler = <A, R>(fn: (...args: A[]) => R) => (
}
};

ipcMain.handle('select-application', ipcHandler(() => {
return dialog.showOpenDialogSync({
ipcMain.handle('select-application', ipcHandler(async () => {
const result = await dialog.showOpenDialog({
properties:
process.platform === 'darwin'
? ['openFile', 'openDirectory', 'treatPackageAsDirectory']
: ['openFile'],
})?.[0];
});

if (!result || result.canceled) return undefined;
else return result.filePaths[0];
}));

// Enable the default context menu
Expand Down

0 comments on commit 9939f1a

Please sign in to comment.