Compare commits

..

No commits in common. "8561b9c6c613305c0cbbe1f6faf3228ed2d92318" and "201ee9813f7311972071fba9e24c1b2c0cf7ee90" have entirely different histories.

2 changed files with 5 additions and 16 deletions

View File

@ -59,7 +59,6 @@ export default {
const toast = useToast() const toast = useToast()
const trackers = inject('trackers') const trackers = inject('trackers')
var webTorrent = null var webTorrent = null
var wireUpdateHandle = null
const player = ref(null) const player = ref(null)
const video = reactive({ const video = reactive({
file: null, file: null,
@ -86,9 +85,6 @@ export default {
if (webTorrent) { if (webTorrent) {
webTorrent.destroy() webTorrent.destroy()
} }
if (wireUpdateHandle) {
clearInterval(wireUpdateHandle)
}
}) })
const onFilesSelected = (f) => { const onFilesSelected = (f) => {
@ -121,16 +117,14 @@ export default {
torrent.on('upload', bytes => { torrent.on('upload', bytes => {
state.uploaded += bytes state.uploaded += bytes
updateWireStatistics()
}) })
torrent.on('wire', wire => { torrent.on('wire', wire => {
updateWireStatistics()
toast.add({ severity: 'info', summary: 'New watcher', detail: 'Someone has joined your screen.', life: 3000 }) toast.add({ severity: 'info', summary: 'New watcher', detail: 'Someone has joined your screen.', life: 3000 })
}) })
wireUpdateHandle = setInterval(() => {
updateWireStatistics()
}, 200)
toast.add({ severity: 'success', summary: 'Video added', detail: `You are now sharing ${video.name}`, life: 5000 }) toast.add({ severity: 'success', summary: 'Video added', detail: `You are now sharing ${video.name}`, life: 5000 })
}) })
} }

View File

@ -65,7 +65,6 @@ export default {
const toast = useToast() const toast = useToast()
const trackers = inject('trackers') const trackers = inject('trackers')
var webTorrent = null var webTorrent = null
var wireUpdateHandle = null
const player = ref(null) const player = ref(null)
const progress = ref() const progress = ref()
const video = reactive({ const video = reactive({
@ -101,14 +100,12 @@ export default {
if (webTorrent) { if (webTorrent) {
webTorrent.destroy() webTorrent.destroy()
} }
if (wireUpdateHandle) {
clearInterval(wireUpdateHandle)
}
}) })
const downloadVideo = (infoHash) => { const downloadVideo = (infoHash) => {
webTorrent.add(infoHash, { announce: trackers }, torrent => { webTorrent.add(infoHash, { announce: trackers }, torrent => {
torrent.on('wire', () => { torrent.on('wire', () => {
updateWireStatistics()
toast.add({ severity: 'info', summary: 'New watcher', detail: 'Someone has joined your screen.', life: 3000 }) toast.add({ severity: 'info', summary: 'New watcher', detail: 'Someone has joined your screen.', life: 3000 })
}) })
@ -117,6 +114,7 @@ export default {
}) })
torrent.on('upload', bytes => { torrent.on('upload', bytes => {
updateWireStatistics()
}) })
torrent.on('download', bytes => { torrent.on('download', bytes => {
@ -126,6 +124,7 @@ export default {
} }
state.downloaded += bytes state.downloaded += bytes
progress.value = state.downloaded / video.size * 100 progress.value = state.downloaded / video.size * 100
updateWireStatistics()
}) })
}) })
} }
@ -149,10 +148,6 @@ export default {
}) })
file.renderTo(player.value) file.renderTo(player.value)
wireUpdateHandle = setInterval(() => {
updateWireStatistics()
}, 200)
} }
const updateWireStatistics = () => { const updateWireStatistics = () => {