diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-29 07:23:54 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-29 07:23:54 +0200 |
commit | a970e88a1753101d2d55139bd7ae44d005c33f44 (patch) | |
tree | fc2a06ce42e69e58bf2c3d4810f7a943e9f29283 /application/palemoon/components/downloads/content/allDownloadsViewOverlay.js | |
parent | 43cebecade19978f231253b221cb36bc7039661b (diff) | |
download | UXP-a970e88a1753101d2d55139bd7ae44d005c33f44.tar UXP-a970e88a1753101d2d55139bd7ae44d005c33f44.tar.gz UXP-a970e88a1753101d2d55139bd7ae44d005c33f44.tar.lz UXP-a970e88a1753101d2d55139bd7ae44d005c33f44.tar.xz UXP-a970e88a1753101d2d55139bd7ae44d005c33f44.zip |
[PALEMOON] Bug 1115369 - Use notifications instead of getViewItem for DownloadsView
Diffstat (limited to 'application/palemoon/components/downloads/content/allDownloadsViewOverlay.js')
-rw-r--r-- | application/palemoon/components/downloads/content/allDownloadsViewOverlay.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js index 054f0405f..ba1aa6092 100644 --- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js +++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js @@ -55,9 +55,8 @@ const NOT_AVAILABLE = Number.MAX_VALUE; * * The caller is also responsible for "passing over" notification from both the * download-view and the places-result-observer, in the following manner: - * - The DownloadsPlacesView object implements getViewItem of the download-view - * pseudo interface. It returns this object (therefore we implement - * onStateChangea and onProgressChange here). + * - The DownloadsPlacesView object implements onDataItemStateChanged and + * onDataItemChanged of the DownloadsView pseudo interface. * - The DownloadsPlacesView object adds itself as a places result observer and * calls this object's placesNodeIconChanged, placesNodeTitleChanged and * placeNodeAnnotationChanged from its callbacks. @@ -557,8 +556,7 @@ DownloadElementShell.prototype = { } }, - /* DownloadView */ - onStateChange: function DES_onStateChange(aOldState) { + onStateChanged(aOldState) { let metaData = this.getDownloadMetaData(); metaData.state = this.dataItem.state; if (aOldState != nsIDM.DOWNLOAD_FINISHED && aOldState != metaData.state) { @@ -572,14 +570,14 @@ DownloadElementShell.prototype = { } this._updateDownloadStatusUI(); + if (this._element.selected) goUpdateDownloadCommands(); else goUpdateCommand("downloadsCmd_clearDownloads"); }, - /* DownloadView */ - onProgressChange: function DES_onProgressChange() { + onChanged() { this._updateDownloadStatusUI(); }, @@ -915,7 +913,7 @@ DownloadsPlacesView.prototype = { // data item. Thus, we also check that we make sure we don't have a view item // already. if (!shouldCreateShell && - aDataItem && this.getViewItem(aDataItem) == null) { + aDataItem && !this._viewItemsForDataItems.has(aDataItem)) { // If there's a past-download-only shell for this download-uri with no // associated data item, use it for the new data item. Otherwise, go ahead // and create another shell. @@ -1034,7 +1032,7 @@ DownloadsPlacesView.prototype = { if (shells.size == 0) throw new Error("Should have had at leaat one shell for this uri"); - let shell = this.getViewItem(aDataItem); + let shell = this._viewItemsForDataItems.get(aDataItem); if (!shells.has(shell)) throw new Error("Missing download element shell in shells list for url"); @@ -1342,8 +1340,15 @@ DownloadsPlacesView.prototype = { this._removeSessionDownloadFromView(aDataItem); }, - getViewItem: function(aDataItem) - this._viewItemsForDataItems.get(aDataItem, null), + // DownloadsView + onDataItemStateChanged(aDataItem, aOldState) { + this._viewItemsForDataItems.get(aDataItem).onStateChanged(aOldState); + }, + + // DownloadsView + onDataItemChanged(aDataItem) { + this._viewItemsForDataItems.get(aDataItem).onChanged(); + }, supportsCommand: function DPV_supportsCommand(aCommand) { if (DOWNLOAD_VIEW_SUPPORTED_COMMANDS.indexOf(aCommand) != -1) { |