diff --git a/renderer/index.js b/renderer/index.js index 13d7f2c1..bbe02a8b 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -372,7 +372,7 @@ function setupIpc () { }) ipcRenderer.on('wt-infohash', (e, ...args) => torrentInfoHash(...args)) - ipcRenderer.on('wt-ready', (e, ...args) => torrentReady(...args)) + ipcRenderer.on('wt-metadata', (e, ...args) => torrentMetadata(...args)) ipcRenderer.on('wt-done', (e, ...args) => torrentDone(...args)) ipcRenderer.on('wt-warning', (e, ...args) => torrentWarning(...args)) ipcRenderer.on('wt-error', (e, ...args) => torrentError(...args)) @@ -626,11 +626,10 @@ function torrentError (torrentKey, message) { } } -function torrentReady (torrentKey, torrentInfo) { +function torrentMetadata (torrentKey, torrentInfo) { // Summarize torrent var torrentSummary = getTorrentSummary(torrentKey) torrentSummary.status = 'downloading' - torrentSummary.ready = true torrentSummary.name = torrentSummary.displayName || torrentInfo.name torrentSummary.path = torrentInfo.path torrentSummary.files = torrentInfo.files diff --git a/renderer/webtorrent.js b/renderer/webtorrent.js index 06391bd4..6b44a748 100644 --- a/renderer/webtorrent.js +++ b/renderer/webtorrent.js @@ -92,13 +92,21 @@ function addTorrentEvents (torrent) { ipc.send('wt-error', torrent.key, err.message)) torrent.on('infoHash', () => ipc.send('wt-infohash', torrent.key, torrent.infoHash)) + torrent.on('metadata', torrentMetadata) torrent.on('ready', torrentReady) torrent.on('done', torrentDone) + function torrentMetadata () { + var info = getTorrentInfo(torrent) + ipc.send('wt-metadata', torrent.key, info) + + updateTorrentProgress() + } + function torrentReady () { var info = getTorrentInfo(torrent) ipc.send('wt-ready', torrent.key, info) - ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info) + ipc.send('wt-ready-' + torrent.infoHash, torrent.key, info) // TODO: hack updateTorrentProgress() } @@ -264,7 +272,7 @@ function startServerFromReadyTorrent (torrent, index, cb) { } ipc.send('wt-server-running', info) - ipc.send('wt-server-' + torrent.infoHash, info) + ipc.send('wt-server-' + torrent.infoHash, info) // TODO: hack }) }