Skip to content

Commit

Permalink
Use async showOpenDialog/showSaveDialog for linux problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Dec 23, 2021
1 parent f778d55 commit 3fa36cf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Main/Bind/StreamBind.ts
Expand Up @@ -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());
}
}

Expand Down

0 comments on commit 3fa36cf

Please sign in to comment.