Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
This sorts installed extensions by updateAvailable (#6634)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaggino committed Mar 28, 2014
1 parent d4eaef3 commit 63d959d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/extensibility/ExtensionManagerViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ define(function (require, exports, module) {
*/
function InstalledViewModel() {
ExtensionManagerViewModel.call(this);

var self = this;
$(ExtensionManager).on("registryDownload", function () {
self._sortFullSet();
self._setInitialFilter();
});
}

InstalledViewModel.prototype = Object.create(ExtensionManagerViewModel.prototype);
Expand Down Expand Up @@ -405,10 +411,19 @@ define(function (require, exports, module) {
var self = this;

this.sortedFullSet = this.sortedFullSet.sort(function (key1, key2) {
var ua1 = self.extensions[key1].installInfo.updateAvailable,
ua2 = self.extensions[key2].installInfo.updateAvailable;
if (ua1 && !ua2) {
return -1;
} else if (!ua1 && ua2) {
return 1;
}

var metadata1 = self.extensions[key1].installInfo.metadata,
metadata2 = self.extensions[key2].installInfo.metadata,
id1 = (metadata1.title || metadata1.name).toLowerCase(),
id2 = (metadata2.title || metadata2.name).toLowerCase();

if (id1 < id2) {
return -1;
} else if (id1 === id2) {
Expand Down Expand Up @@ -483,4 +498,4 @@ define(function (require, exports, module) {

exports.RegistryViewModel = RegistryViewModel;
exports.InstalledViewModel = InstalledViewModel;
});
});

0 comments on commit 63d959d

Please sign in to comment.