From 093d810b90dfc4b61a5b8f5b5a05eb9c58f3d6c6 Mon Sep 17 00:00:00 2001 From: DC Date: Mon, 7 Mar 2016 00:11:43 -0800 Subject: [PATCH] Remove updateThrottled --- package.json | 1 - renderer/index.js | 17 +++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b1933174..339eaeac 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "main-loop": "^3.2.0", "network-address": "^1.1.0", "pretty-bytes": "^3.0.0", - "throttleit": "^1.0.0", "upload-element": "^1.0.1", "virtual-dom": "^2.1.1", "webtorrent": "^0.82.1" diff --git a/renderer/index.js b/renderer/index.js index cd6d2a34..873280ba 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -10,7 +10,6 @@ var mainLoop = require('main-loop') var networkAddress = require('network-address') var path = require('path') var state = require('./state') -var throttle = require('throttleit') var torrentPoster = require('./lib/torrent-poster') var WebTorrent = require('webtorrent') var cfg = require('application-config')('WebTorrent') @@ -30,7 +29,7 @@ global.WEBTORRENT_ANNOUNCE = createTorrent.announceList return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0 }) -var vdomLoop, updateThrottled +var vdomLoop /** * Called once when the application loads. (Not once per window.) @@ -56,11 +55,9 @@ function init () { document.body.appendChild(vdomLoop.target) // Calling update() updates the UI given the current state - // For performance, we don't want to do this too often. Hence, events that - // affect the UI can be v frequent--like torrent progress updates--call - // updateThrottled() instead, which calls update() at most once a second. - updateThrottled = throttle(update, 1000) - setInterval(updateThrottled, 1000) + // Do this at least once a second to show latest state for each torrent + // (eg % downloaded) and to keep the cursor in sync when playing a video + setInterval(update, 1000) // All state lives in state.js. `state.saved` is read from and written to a // file. All other state is ephemeral. Here we'll load state.saved: @@ -208,9 +205,7 @@ function loadState () { electron.ipcRenderer.send('log', 'loaded state from ' + cfg.filePath) state.saved = data if (!state.saved.torrents) state.saved.torrents = [] - state.saved.torrents.forEach(function (torrent) { - startTorrenting(torrent.magnetURI) - }) + state.saved.torrents.forEach((x) => startTorrenting(x.infoHash)) }) } @@ -293,8 +288,6 @@ function seed (files) { function addTorrentEvents (torrent) { torrent.on('infoHash', update) - torrent.on('download', updateThrottled) - torrent.on('upload', updateThrottled) torrent.on('ready', torrentReady) torrent.on('done', torrentDone)