This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Show update notification icon on Extension Manager "Installed" tab #5838
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ define(function (require, exports, module) { | |
*/ | ||
ExtensionManagerViewModel.prototype.message = null; | ||
|
||
/** | ||
* @type {number} | ||
* Number to show in tab's notification icon. No icon shown if 0. | ||
*/ | ||
ExtensionManagerViewModel.prototype.notifyCount = 0; | ||
|
||
/** | ||
* @private {$.Promise} | ||
* Internal use only to track when initialization fails, see usage in _updateMessage. | ||
|
@@ -374,6 +380,8 @@ define(function (require, exports, module) { | |
}); | ||
this._sortFullSet(); | ||
this._setInitialFilter(); | ||
this._countUpdates(); | ||
|
||
return new $.Deferred().resolve().promise(); | ||
}; | ||
|
||
|
@@ -399,6 +407,20 @@ define(function (require, exports, module) { | |
}); | ||
}; | ||
|
||
/** | ||
* @private | ||
* Updates notifyCount based on number of extensions with an update available | ||
*/ | ||
InstalledViewModel.prototype._countUpdates = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should have a doc comment |
||
var self = this; | ||
this.notifyCount = 0; | ||
this.sortedFullSet.forEach(function (key) { | ||
if (self.extensions[key].installInfo.updateAvailable) { | ||
self.notifyCount++; | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* @private | ||
* Updates the initial set and filter as necessary when the status of an extension changes, | ||
|
@@ -412,6 +434,7 @@ define(function (require, exports, module) { | |
if (index !== -1 && !this.extensions[id].installInfo) { | ||
// This was in our set, but was uninstalled. Remove it. | ||
this.sortedFullSet.splice(index, 1); | ||
this._countUpdates(); // may also affect update count | ||
refilter = true; | ||
} else if (index === -1 && this.extensions[id].installInfo) { | ||
// This was not in our set, but is now installed. Add it and resort. | ||
|
@@ -422,6 +445,12 @@ define(function (require, exports, module) { | |
if (refilter) { | ||
this.filter(this._lastQuery || "", true); | ||
} | ||
|
||
if (this.extensions[id].installInfo) { | ||
// If our count of available updates may have been affected, re-count | ||
this._countUpdates(); | ||
} | ||
|
||
ExtensionManagerViewModel.prototype._handleStatusChange.call(this, e, id); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should have a doc comment.