From b23131a5b44b1f7a70c6c10537339ef67ec63c9c Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Tue, 30 Aug 2011 02:49:01 +0000 Subject: [PATCH] (trunk web) #4452 "file list not refreshing" -- instead of only requesting file info for the inspector when the inspector is opened (and also when torrent selection changes while the inspector is open), keep re-requesting the file info util we've got it. That way if the first request fails, we'll pick it up on subsequent updates. --- web/javascript/torrent.js | 1 + web/javascript/transmission.js | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index 6596b1a2b..a0ea38924 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -236,6 +236,7 @@ Torrent.prototype = isFinished: function() { return this.fields.isFinished; }, // derived accessors + hasExtraInfo: function() { return 'hashString' in this.fields; }, isSeeding: function() { return this.getStatus() === Torrent._StatusSeed; }, isStopped: function() { return this.getStatus() === Torrent._StatusStopped; }, isChecking: function() { return this.getStatus() === Torrent._StatusCheck; }, diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 45d4abd48..b5741f595 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -448,7 +448,7 @@ Transmission.prototype = selectionChanged: function() { if (this[Prefs._ShowInspector]) - this.refreshInspectorTorrents(true); + this.refreshInspectorTorrents(); this.updateButtonStates(); this.updateInspector(); @@ -1076,7 +1076,19 @@ Transmission.prototype = this.remote.updateTorrents(null, fields, this.updateFromTorrentGet, this); }, - refreshInspectorTorrents: function(full) + needsExtraInfo: function(ids) + { + var i, id, tor; + + for (i=0; id=ids[i]; ++i) + if ((tor = this._torrents[id])) + if (!tor.hasExtraInfo()) + return true; + + return false; + }, + + refreshInspectorTorrents: function(full) { // some torrent fields are only used by the inspector, so we defer loading them // until the user is viewing the torrent in the inspector. @@ -1084,7 +1096,7 @@ Transmission.prototype = var ids = this.getSelectedTorrentIds(); if (ids && ids.length) { var fields = ['id'].concat(Torrent.Fields.StatsExtra); - if (full) + if (this.needsExtraInfo(ids)) fields = fields.concat(Torrent.Fields.InfoExtra); this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this); } @@ -1827,8 +1839,8 @@ Transmission.prototype = delete this._periodic_inspector_refresh; if (visible) { var tr = this; - this._periodic_inspector_refresh = setInterval(function() {tr.refreshInspectorTorrents(false);},2000); - this.refreshInspectorTorrents(true); + this._periodic_inspector_refresh = setInterval(function() {tr.refreshInspectorTorrents();},2000); + this.refreshInspectorTorrents(); } // update the ui widgetry -- 2.40.0