Skip to content

Commit

Permalink
Use promise then() instead of catch() with callbacks
Browse files Browse the repository at this point in the history
Addresses my review here: #1419 (review)
  • Loading branch information
feross committed Sep 7, 2019
1 parent 647eaf5 commit dd13de5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/renderer/lib/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/webtorrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dd13de5

Please sign in to comment.