| Index: remoting/webapp/crd/js/host_list.js
|
| diff --git a/remoting/webapp/crd/js/host_list.js b/remoting/webapp/crd/js/host_list.js
|
| index d75224f7f1fdaacd459579699f39a3389af9160c..2cf7628b325c420d0f9ada18168468c84a9e68e1 100644
|
| --- a/remoting/webapp/crd/js/host_list.js
|
| +++ b/remoting/webapp/crd/js/host_list.js
|
| @@ -116,7 +116,7 @@ remoting.HostList.prototype.load = function(onDone) {
|
| if (items[remoting.HostList.HOSTS_KEY]) {
|
| var cached = base.jsonParseSafe(items[remoting.HostList.HOSTS_KEY]);
|
| if (cached) {
|
| - that.hosts_ = /** @type {Array.<remoting.Host>} */ cached;
|
| + that.hosts_ = /** @type {Array.<remoting.Host>} */ (cached);
|
| } else {
|
| console.error('Invalid value for ' + remoting.HostList.HOSTS_KEY);
|
| }
|
| @@ -188,11 +188,26 @@ remoting.HostList.prototype.refresh = function(onDone) {
|
| */
|
| remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) {
|
| this.lastError_ = '';
|
| + this.hosts_ = hosts;
|
| + this.sortHosts_();
|
| + this.save_();
|
| + this.loadingIndicator_.classList.remove('loading');
|
| + onDone(this.lastError_ == '');
|
| +};
|
| +
|
| +/**
|
| + * Sort the internal list of hosts.
|
| + *
|
| + * @suppress {reportUnknownTypes}
|
| + * @return {void} Nothing.
|
| + */
|
| +remoting.HostList.prototype.sortHosts_ = function() {
|
| /**
|
| * Sort hosts, first by ONLINE/OFFLINE status and then by host-name.
|
| *
|
| * @param {remoting.Host} a
|
| * @param {remoting.Host} b
|
| + * @return {number}
|
| */
|
| var cmp = function(a, b) {
|
| if (a.status < b.status) {
|
| @@ -208,10 +223,8 @@ remoting.HostList.prototype.onHostListResponse_ = function(onDone, hosts) {
|
| }
|
| return 0;
|
| };
|
| - this.hosts_ = /** @type {Array.<remoting.Host>} */ hosts.sort(cmp);
|
| - this.save_();
|
| - this.loadingIndicator_.classList.remove('loading');
|
| - onDone(this.lastError_ == '');
|
| +
|
| + this.hosts_ = this.hosts_.sort(cmp);
|
| };
|
|
|
| /**
|
|
|