From 600646b6cee6de4112d7d91afe5cf36bf6a00800 Mon Sep 17 00:00:00 2001 From: gpatarin Date: Sat, 9 Nov 2019 23:43:03 +0100 Subject: [PATCH 1/2] Making the save file dialog sync to ensure working properly on MacOS and others --- .../controllers/torrent-list-controller.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index b723cf4d..1fa9f98a 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -299,15 +299,15 @@ module.exports = class TorrentListController { ] } - electron.remote.dialog.showSaveDialog(win, opts, function (savePath) { - console.log('Saving torrent ' + torrentKey + ' to ' + savePath) - if (!savePath) return // They clicked Cancel - const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) - fs.readFile(torrentPath, function (err, torrentFile) { + const savePath = electron.remote.dialog.showSaveDialogSync(win, opts) + + console.log('Saving torrent ' + torrentKey + ' to ' + savePath) + if (!savePath) return // They clicked Cancel + const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) + fs.readFile(torrentPath, function (err, torrentFile) { + if (err) return dispatch('error', err) + fs.writeFile(savePath, torrentFile, function (err) { if (err) return dispatch('error', err) - fs.writeFile(savePath, torrentFile, function (err) { - if (err) return dispatch('error', err) - }) }) }) } From f30343b8210ae47a3a55afb6f1a150b2061805a0 Mon Sep 17 00:00:00 2001 From: Gael Patarin Date: Tue, 26 Nov 2019 14:30:09 +0100 Subject: [PATCH 2/2] Added buttonLabel as Save in the save dialog --- src/renderer/controllers/torrent-list-controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index 1fa9f98a..fbfba2e2 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -296,13 +296,14 @@ module.exports = class TorrentListController { filters: [ { name: 'Torrent Files', extensions: ['torrent'] }, { name: 'All Files', extensions: ['*'] } - ] + ], + buttonLabel: 'Save' } const savePath = electron.remote.dialog.showSaveDialogSync(win, opts) - console.log('Saving torrent ' + torrentKey + ' to ' + savePath) if (!savePath) return // They clicked Cancel + console.log('Saving torrent ' + torrentKey + ' to ' + savePath) const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) fs.readFile(torrentPath, function (err, torrentFile) { if (err) return dispatch('error', err)