From dd13de5f65f07c9a71e8150c8e4a5107ad667b1d Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 7 Sep 2019 11:10:53 -0700 Subject: [PATCH] Use promise then() instead of catch() with callbacks Addresses my review here: https://github.com/webtorrent/webtorrent-desktop/pull/1419#pullrequestreview-285182318 --- src/renderer/lib/state.js | 6 ++++-- src/renderer/webtorrent.js | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/renderer/lib/state.js b/src/renderer/lib/state.js index bfbd1f2b00..9e2e1a5251 100644 --- a/src/renderer/lib/state.js +++ b/src/renderer/lib/state.js @@ -151,8 +151,10 @@ function setupStateSaved (cb) { }) Promise.all(tasks) - .then(() => cb(null, saved)) - .catch(err => cb(err)) + .then( + () => cb(null, saved), + err => cb(err) + ) function createTorrentObject (t) { // TODO: Doing several fs.readFileSync calls during first startup is not ideal diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index 8493cf8a67..3934ce7cab 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -358,11 +358,15 @@ function getAudioMetadata (infoHash, index) { : mm.parseStream(file.createReadStream(), file.name, options) onMetaData - .then(() => { - console.log(`metadata for file='${file.name}' completed.`) - }).catch(function (err) { - return console.log('error getting audio metadata for ' + infoHash + ':' + index, err) - }) + .then( + () => console.log(`metadata for file='${file.name}' completed.`), + err => { + console.log( + `error getting audio metadata for ${infoHash}:${index}`, + err + ) + } + ) } function selectFiles (torrentOrInfoHash, selections) {