Skip to content

Commit 7faf2e1

Browse files
Fix open and save dialog to use Promise
1 parent 905e568 commit 7faf2e1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

app/src/main.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ let menuOpen = (item, focusedWindow) => {
205205
{
206206
properties: ['openFile'],
207207
filters: fileExtensions
208-
}, (paths) => {
209-
if (paths && paths.length > 0) { newWorksheet(paths[0]) }
208+
}).then((result) => {
209+
console.log(result)
210+
if (!result.canceled && result.filePaths) {
211+
result.filePaths.forEach(path => { newWorksheet(path) })
212+
}
210213
})
211214
}
212215

@@ -235,12 +238,13 @@ BrowserWindow.prototype.saveFile = function () {
235238

236239
BrowserWindow.prototype.saveFileAs = function () {
237240
let win = this
238-
dialog.showSaveDialog(win,
239-
{ filters: fileExtensions }, (path) => {
240-
if (path) {
241-
win.setFilepath(path)
242-
win.saveFile()
243-
}
241+
dialog.showSaveDialog(win, {
242+
filters: fileExtensions
243+
}).then((result) => {
244+
if (!result.canceled && result.filePath) {
245+
win.setFilepath(result.filePath)
246+
win.saveFile()
247+
}
244248
})
245249
}
246250

0 commit comments

Comments
 (0)