summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/downloads/DownloadsCommon.jsm
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-07-29 13:12:21 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-07-29 13:12:21 +0200
commit551c6ff0463b555d32c51d22163318b7204c5388 (patch)
tree739505628857b3be705e8de4a9f47baf34b28f5d /application/palemoon/components/downloads/DownloadsCommon.jsm
parent0b15a2b89e6615c5e68f75c2515fe0cdf49178e4 (diff)
downloadUXP-551c6ff0463b555d32c51d22163318b7204c5388.tar
UXP-551c6ff0463b555d32c51d22163318b7204c5388.tar.gz
UXP-551c6ff0463b555d32c51d22163318b7204c5388.tar.lz
UXP-551c6ff0463b555d32c51d22163318b7204c5388.tar.xz
UXP-551c6ff0463b555d32c51d22163318b7204c5388.zip
[PALEMOON] Bug 1129896 - Part 2 of 2 - Convert the shared front-end code to a JavaScript code module
Diffstat (limited to 'application/palemoon/components/downloads/DownloadsCommon.jsm')
-rw-r--r--application/palemoon/components/downloads/DownloadsCommon.jsm21
1 files changed, 15 insertions, 6 deletions
diff --git a/application/palemoon/components/downloads/DownloadsCommon.jsm b/application/palemoon/components/downloads/DownloadsCommon.jsm
index 73467e813..efe31ce05 100644
--- a/application/palemoon/components/downloads/DownloadsCommon.jsm
+++ b/application/palemoon/components/downloads/DownloadsCommon.jsm
@@ -373,6 +373,17 @@ this.DownloadsCommon = {
},
/**
+ * Helper function required because the Downloads Panel and the Downloads View
+ * don't share the controller yet.
+ */
+ removeAndFinalizeDownload(download) {
+ Downloads.getList(Downloads.ALL)
+ .then(list => list.remove(download))
+ .then(() => download.finalize(true))
+ .catch(Cu.reportError);
+ },
+
+ /**
* Given an iterable collection of Download objects, generates and returns
* statistics about that collection.
*
@@ -383,7 +394,6 @@ this.DownloadsCommon = {
*
* numActive : The total number of downloads.
* numPaused : The total number of paused downloads.
- * numScanning : The total number of downloads being scanned.
* numDownloading : The total number of downloads being downloaded.
* totalSize : The total size of all downloads once completed.
* totalTransferred: The total amount of transferred data for these
@@ -397,7 +407,6 @@ this.DownloadsCommon = {
let summary = {
numActive: 0,
numPaused: 0,
- numScanning: 0,
numDownloading: 0,
totalSize: 0,
totalTransferred: 0,
@@ -677,7 +686,7 @@ DownloadsDataCtor.prototype = {
*/
get canRemoveFinished()
{
- for (let download of this.oldDownloadStates.keys()) {
+ for (let download of this.downloads) {
// Stopped, paused, and failed downloads with partial data are removed.
if (download.stopped && !(download.canceled && download.hasPartialData)) {
return true;
@@ -832,7 +841,7 @@ DownloadsDataCtor.prototype = {
//let loadedItemsArray = [dataItem
// for each (dataItem in this.dataItems)
// if (dataItem)];
- let downloadsArray = [...this.oldDownloadStates.keys()];
+ let downloadsArray = [...this.downloads];
downloadsArray.sort((a, b) => b.startTime - a.startTime);
downloadsArray.forEach(download => aView.onDownloadAdded(download, false));
@@ -1659,7 +1668,7 @@ DownloadsIndicatorDataCtor.prototype = {
* to generate statistics about the downloads we care about - in this case,
* it's all active downloads.
*/
- _activeDownloads: function* () {
+ * _activeDownloads() {
let downloads = this._isPrivate ? PrivateDownloadsData.downloads
: DownloadsData.downloads;
for (let download of downloads) {
@@ -1865,7 +1874,7 @@ DownloadsSummaryData.prototype = {
* it's the downloads in this._downloads after the first few to exclude,
* which was set when constructing this DownloadsSummaryData instance.
*/
- _downloadsForSummary: function* () {
+ * _downloadsForSummary() {
if (this._downloads.length > 0) {
for (let i = this._numToExclude; i < this._downloads.length; ++i) {
yield this._downloads[i];