electron-in-action/firesale

dialog.showOpenDialog doesn't return an array of string but a promise.

Opened this issue · 1 comments

Listing 4.2 doesn't work since dialog.showOpenDialog doesn't return an array of string but a promise according to the doc.
Hence the listing 4.2 need to be modify in order to take it into account.

const getFileFromUser = () => {
  const files = dialog.showOpenDialog({
    properties: ["openFile"],
  });
  files
    .then((value) => {
      if (value.canceled == true) return;
      console.log(value.filePaths);
    })
    .catch((err) => console.log(err));
};

Change showOpenDialog to showOpenDialogSync. There are a number of places where the code doesn't work in current versions of Electron.