diff --git a/src/renderer/controllers/torrent-controller.js b/src/renderer/controllers/torrent-controller.js index e968f8b6..dda18d5e 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 ef40b662..7864ca5f 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -360,7 +360,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-done', () => controllers.torrentList().resumePausedTorrents()) diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index 3934ce7c..7b42dacd 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -147,7 +147,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)