Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: remoting/webapp/crd/js/host_list.js

Issue 803653004: Update Chromoting to use /third_party/closure_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused types Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};
/**

Powered by Google App Engine
This is Rietveld 408576698