[PALEMOON] Bug 1129896 - Part 2 of 2 - Convert the shared front-end code to a JavaScript code module

This commit is contained in:
janekptacijarabaci 2018-07-29 13:12:21 +02:00 • committed by Roy Tam
commit 83ba13fdac
8 changed files with 94 additions and 64 deletions

View file

@ -372,6 +372,17 @@ this.DownloadsCommon = {
return nsIDM.DOWNLOAD_NOTSTARTED;
},
/**
* 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];