fix torrent propagation in w2g

This commit is contained in:
ThaUnknown 2022-04-30 18:37:01 +02:00
parent 7030b5516e
commit 26da1a4c3b
3 changed files with 10 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "2.0.3",
"version": "2.0.4",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"main": "src/index.js",
"homepage": "https://github.com/ThaUnknown/miru#readme",

View file

@ -64,10 +64,10 @@
})
queueMicrotask(() => {
client.on('torrent', ({ detail }) => {
if (!detail.every((v, i) => v === playerState.file[i])) {
playerState.file = detail
emit('torrent', { file: detail })
client.on('magnet', ({ detail }) => {
if (detail.hash !== playerState.hash) {
playerState.hash = detail.hash
emit('torrent', detail)
}
})
})
@ -81,7 +81,7 @@
const playerState = {
paused: null,
time: null,
file: []
hash: null
}
function cancel() {
@ -153,9 +153,9 @@
break
}
case 'torrent': {
if (!data.file.every((v, i) => v === playerState.file[i])) {
playerState.file = data.file
add(data.file)
if (data.hash !== playerState.hash) {
playerState.hash = data.hash
add(data.magnet)
}
break
}

View file

@ -41,6 +41,7 @@ class TorrentClient extends WebTorrent {
})
this.dispatch('files', files)
this.dispatch('pieces', torrent.pieces.length)
this.dispatch('magnet', { magnet: torrent.magnetURI, hash: torrent.infoHash })
this.dispatch('torrent', Array.from(torrent.torrentFile))
})