z-edit / zedit

An integrated development environment for Bethesda Plugin Files.
https://z-edit.github.io
MIT License
304 stars 55 forks source link

Outdated dialog.showOpenDialog() usage #238

Open chanoc1 opened 2 years ago

chanoc1 commented 2 years ago

fh.SelectDirectory() and fh.selectFile both call dialog.showOpenDialog() expecting old behavior (expecting to get an array of strings representing file paths).

However, since Electron 6.0.0, dialog.showOpenDialog() returns a Promise object.

The code needs to be updated to reflect this, since the current code will always return undefined.

Without this, any file picker dialogues opened won't actually work.

chanoc1 commented 2 years ago

A quick and dirty fix would be to switch over to dialog.showOpenDialogSync(), which is basically the old behavior. (returns an array of strings representing file paths)

However, since it is a synchronous function, the rest of the program cannot be interacted with until a file has been chosen.

This is in direct contrast to the current behavior, where the user can still freely interact with the program, even with with the modal that opened the file browser closed. Perhaps this an oversight?

EDIT: Actually, upon further inspection, you can actually still click things when a dialog from dialog.showOpenDialogSync() is open. It just won't update until you pick a file.

matortheeternal commented 2 years ago

I prefer the synchronous behavior because this dialog is meant to be modal - it should block the user from interacting with the program while it's open.