From 3fa36cf94b132fe03c994cbe6bb415e80a21003d Mon Sep 17 00:00:00 2001 From: Watson Date: Sat, 4 Dec 2021 23:43:32 +0900 Subject: [PATCH] Use async showOpenDialog/showSaveDialog for linux problem https://github.com/electron/electron/issues/31152 --- src/Main/Bind/StreamBind.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Main/Bind/StreamBind.ts b/src/Main/Bind/StreamBind.ts index 28b16b1e..64dce1cf 100644 --- a/src/Main/Bind/StreamBind.ts +++ b/src/Main/Bind/StreamBind.ts @@ -22,18 +22,16 @@ class _StreamBind { private async exportStreams(streams: any[]) { const defaultPath = app.getPath('downloads') + '/jasper-streams.json'; - const filePath = dialog.showSaveDialogSync({defaultPath}); + const { filePath } = await dialog.showSaveDialog({defaultPath}); if (!filePath) return; fs.writeFileSync(filePath, JSON.stringify(streams, null, 2)); } private async importStreams() { const defaultPath = app.getPath('downloads') + '/jasper-streams.json'; - const tmp = dialog.showOpenDialogSync({defaultPath, properties: ['openFile']}); - if (!tmp || !tmp.length) return; - - const filePath = tmp[0]; - return JSON.parse(fs.readFileSync(filePath).toString()); + const { filePaths } = await dialog.showOpenDialog({defaultPath, properties: ['openFile']}); + if (!filePaths) return; + return JSON.parse(fs.readFileSync(filePaths[0]).toString()); } }