Changeset 12765


Ignore:
Timestamp:
Aug 26, 2011, 11:34:43 PM (12 years ago)
Author:
jordan
Message:

(trunk web) better bootstrapping when first loading all the torrents.

Location:
trunk/web/javascript
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/javascript/torrent.js

    r12763 r12765  
    209209        getLeftUntilDone: function() { return this.fields.leftUntilDone; },
    210210        getMetadataPercentComplete: function() { return this.fields.metadataPercentComplete; },
    211         getName: function() { return this.fields.name; },
     211        getName: function() { return this.fields.name || 'Unknown'; },
    212212        getPeers: function() { return this.fields.peers; },
    213213        getPeersConnected: function() { return this.fields.peersConnected; },
     
    256256                        case Torrent._StatusSeedWait:       return 'Queued for seeding';
    257257                        case Torrent._StatusSeed:           return 'Seeding';
    258                         default:                            return 'error';
     258                        case null:
     259                        case undefined:                     return 'Unknown';
     260                        default:                            return 'Error';
    259261                }
    260262        },
     
    282284                var f = this.fields;
    283285                if (!f.collatedName) {
    284                         var name = this.getName();
     286                        var name = this.fields.name;
    285287                        if (name)
    286288                                f.collatedName = name.toLowerCase();
  • trunk/web/javascript/transmission.js

    r12762 r12765  
    10481048        updateFromTorrentGet: function(updates, removed_ids)
    10491049        {
    1050                 var new_ids = [];
     1050                var needinfo = [];
    10511051
    10521052                for (var i=0, o; o=updates[i]; ++i) {
     
    10591059                                t = tr._torrents[id] = new Torrent(o);
    10601060                                $(t).bind('dataChanged',function(ev) {tr.onTorrentChanged(ev);});
    1061                                 new_ids.push(id);
     1061                                if(!('name' in t.fields) || !('status' in t.fields)) // missing some fields...
     1062                                        needinfo.push(id);
    10621063                        }
    10631064                }
    10641065
    1065                 if (new_ids.length) {
     1066                if (needinfo.length) {
    10661067                        // whee, new torrents! get their initial information.
    10671068                        var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
    1068                         this.remote.updateTorrents(new_ids, fields, this.updateFromTorrentGet, this);
     1069                        this.remote.updateTorrents(needinfo, fields, this.updateFromTorrentGet, this);
    10691070                        this.refilterSoon();
    10701071                }
     
    10921093                // to bootstrap, we only need to ask for the servers's torrents' ids.
    10931094                // updateFromTorrentGet() automatically asks for the rest of the info when it gets a new id.
    1094                 this.remote.updateTorrents(null, ['id'], this.updateFromTorrentGet, this);
     1095                var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
     1096                this.remote.updateTorrents(null, fields, this.updateFromTorrentGet, this);
    10951097        },
    10961098
Note: See TracChangeset for help on using the changeset viewer.