diff --git a/src/renderer/controllers/torrent-controller.js b/src/renderer/controllers/torrent-controller.js index 73b6757d..ccc72664 100644 --- a/src/renderer/controllers/torrent-controller.js +++ b/src/renderer/controllers/torrent-controller.js @@ -10,7 +10,7 @@ module.exports = class TorrentController { this.state = state } - torrentInfoHash (torrentKey, infoHash) { + torrentParsed (torrentKey, infoHash, magnetURI) { let torrentSummary = this.getTorrentSummary(torrentKey) console.log('got infohash for %s torrent %s', torrentSummary ? 'existing' : 'new', torrentKey) @@ -33,6 +33,7 @@ module.exports = class TorrentController { } torrentSummary.infoHash = infoHash + torrentSummary.magnetURI = magnetURI dispatch('update') } @@ -62,7 +63,6 @@ module.exports = class TorrentController { torrentSummary.status = 'downloading' torrentSummary.name = torrentSummary.displayName || torrentInfo.name torrentSummary.path = torrentInfo.path - torrentSummary.magnetURI = torrentInfo.magnetURI // TODO: make torrentInfo immutable, save separately as torrentSummary.info // For now, check whether torrentSummary.files has already been set: const hasDetailedFileInfo = torrentSummary.files && torrentSummary.files[0].path diff --git a/src/renderer/main.js b/src/renderer/main.js index 26611d5c..6a644e82 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -336,7 +336,7 @@ function setupIpc () { ipcRenderer.on('windowBoundsChanged', onWindowBoundsChanged) const tc = controllers.torrent() - ipcRenderer.on('wt-infohash', (e, ...args) => tc.torrentInfoHash(...args)) + ipcRenderer.on('wt-parsed', (e, ...args) => tc.torrentParsed(...args)) ipcRenderer.on('wt-metadata', (e, ...args) => tc.torrentMetadata(...args)) ipcRenderer.on('wt-done', (e, ...args) => tc.torrentDone(...args)) ipcRenderer.on('wt-warning', (e, ...args) => tc.torrentWarning(...args)) diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index b080beca..b8288a28 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -148,7 +148,7 @@ function addTorrentEvents (torrent) { torrent.on('error', (err) => ipc.send('wt-error', torrent.key, err.message)) torrent.on('infoHash', () => - ipc.send('wt-infohash', torrent.key, torrent.infoHash)) + ipc.send('wt-parsed', torrent.key, torrent.infoHash, torrent.magnetURI)) torrent.on('metadata', torrentMetadata) torrent.on('ready', torrentReady) torrent.on('done', torrentDone)