Skip to content

Commit 0b6652c

Browse files
author
Christopher Willis-Ford
committed
fix save & quit dialogs for Electron 6 API changes
1 parent 9b22411 commit 0b6652c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ const createMainWindow = () => {
104104
const extNameNoDot = extName.replace(/^\./, '');
105105
options.filters = [getFilterForExtension(extNameNoDot)];
106106
}
107-
const userChosenPath = dialog.showSaveDialog(window, options);
107+
const userChosenPath = dialog.showSaveDialogSync(window, options);
108108
if (userChosenPath) {
109+
// WARNING: `setSavePath` on this item is only valid during the `will-download` event. Calling the async
110+
// version of `showSaveDialog` means the event will finish before we get here, so `setSavePath` will be
111+
// ignored. For that reason we need to call `showSaveDialogSync` above.
109112
item.setSavePath(userChosenPath);
110113
if (isProjectSave) {
111114
const newProjectTitle = path.basename(userChosenPath, extName);
@@ -125,7 +128,7 @@ const createMainWindow = () => {
125128
});
126129

127130
webContents.on('will-prevent-unload', ev => {
128-
const choice = dialog.showMessageBox(window, {
131+
const choice = dialog.showMessageBoxSync(window, {
129132
type: 'question',
130133
message: 'Leave Scratch?',
131134
detail: 'Any unsaved changes will be lost.',

0 commit comments

Comments
 (0)