Skip to content

Commit 9939f1a

Browse files
committed
Use async app picker in IPC API to avoid UI freeze
Without this, the rest of the UI visually freezes (boxes repeating if the dialog is dragged around) while the file selector is open.
1 parent 6e374a0 commit 9939f1a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,16 @@ const ipcHandler = <A, R>(fn: (...args: A[]) => R) => (
614614
}
615615
};
616616

617-
ipcMain.handle('select-application', ipcHandler(() => {
618-
return dialog.showOpenDialogSync({
617+
ipcMain.handle('select-application', ipcHandler(async () => {
618+
const result = await dialog.showOpenDialog({
619619
properties:
620620
process.platform === 'darwin'
621621
? ['openFile', 'openDirectory', 'treatPackageAsDirectory']
622622
: ['openFile'],
623-
})?.[0];
623+
});
624+
625+
if (!result || result.canceled) return undefined;
626+
else return result.filePaths[0];
624627
}));
625628

626629
// Enable the default context menu

0 commit comments

Comments
 (0)