]> granicus.if.org Git - transmission/commitdiff
(trunk web) better bootstrapping when first loading all the torrents.
authorJordan Lee <jordan@transmissionbt.com>
Fri, 26 Aug 2011 23:34:43 +0000 (23:34 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Fri, 26 Aug 2011 23:34:43 +0000 (23:34 +0000)
web/javascript/torrent.js
web/javascript/transmission.js

index a010d955d82b67f3f84b2f30734c8f133d479681..a7f8f7aa383ff17ed98bb4e82890ef504b562336 100644 (file)
@@ -208,7 +208,7 @@ Torrent.prototype =
        getId: function() { return this.fields.id; },
        getLeftUntilDone: function() { return this.fields.leftUntilDone; },
        getMetadataPercentComplete: function() { return this.fields.metadataPercentComplete; },
-       getName: function() { return this.fields.name; },
+       getName: function() { return this.fields.name || 'Unknown'; },
        getPeers: function() { return this.fields.peers; },
        getPeersConnected: function() { return this.fields.peersConnected; },
        getPeersGettingFromUs: function() { return this.fields.peersGettingFromUs; },
@@ -255,7 +255,9 @@ Torrent.prototype =
                        case Torrent._StatusDownload:       return 'Downloading';
                        case Torrent._StatusSeedWait:       return 'Queued for seeding';
                        case Torrent._StatusSeed:           return 'Seeding';
-                       default:                            return 'error';
+                       case null:
+                       case undefined:                     return 'Unknown';
+                       default:                            return 'Error';
                }
        },
        seedRatioLimit: function(controller){
@@ -281,7 +283,7 @@ Torrent.prototype =
        getCollatedName: function() {
                var f = this.fields;
                if (!f.collatedName) {
-                       var name = this.getName();
+                       var name = this.fields.name;
                        if (name)
                                f.collatedName = name.toLowerCase();
                }
index 5806cdad2d1c3b4e923d23ede2733eea6ca5fe3f..03fca798dded1ac6121c0e06cc125b782ed1af34 100644 (file)
@@ -1047,7 +1047,7 @@ Transmission.prototype =
 
        updateFromTorrentGet: function(updates, removed_ids)
        {
-               var new_ids = [];
+               var needinfo = [];
 
                for (var i=0, o; o=updates[i]; ++i) {
                        var t;
@@ -1058,14 +1058,15 @@ Transmission.prototype =
                                var tr = this;
                                t = tr._torrents[id] = new Torrent(o);
                                $(t).bind('dataChanged',function(ev) {tr.onTorrentChanged(ev);});
-                               new_ids.push(id);
+                               if(!('name' in t.fields) || !('status' in t.fields)) // missing some fields...
+                                       needinfo.push(id);
                        }
                }
 
-               if (new_ids.length) {
+               if (needinfo.length) {
                        // whee, new torrents! get their initial information.
                        var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
-                       this.remote.updateTorrents(new_ids, fields, this.updateFromTorrentGet, this);
+                       this.remote.updateTorrents(needinfo, fields, this.updateFromTorrentGet, this);
                        this.refilterSoon();
                }
 
@@ -1091,7 +1092,8 @@ Transmission.prototype =
        {
                // to bootstrap, we only need to ask for the servers's torrents' ids.
                // updateFromTorrentGet() automatically asks for the rest of the info when it gets a new id.
-               this.remote.updateTorrents(null, ['id'], this.updateFromTorrentGet, this);
+               var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
+               this.remote.updateTorrents(null, fields, this.updateFromTorrentGet, this);
        },
 
        refreshInspectorTorrents: function(full)