mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* Add HTTP(S) file web server with temp URLs * Get temp web d/l from file list * Add File area filter editor (all file area stuff will be rename to file "base" later) * Concept of "listening servers" vs "login servers" * Ability to get servers by their package name * New MCI: %FN: File Base active filter name * Some ES6 updates * VC resetInitialFocus() to set focus to explicit/detected initial focus field * Limit what is dumped out when logging form data
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/* jslint node: true */
|
|
'use strict';
|
|
|
|
const FileEntry = require('./file_entry.js');
|
|
|
|
module.exports = class DownloadQueue {
|
|
constructor(client) {
|
|
this.client = client;
|
|
|
|
this.loadFromProperty(client);
|
|
}
|
|
|
|
toggle(fileEntry) {
|
|
if(this.isQueued(fileEntry)) {
|
|
this.client.user.downloadQueue = this.client.user.downloadQueue.filter(e => fileEntry.fileId !== e.fileId);
|
|
} else {
|
|
this.add(fileEntry);
|
|
}
|
|
}
|
|
|
|
add(fileEntry) {
|
|
this.client.user.downloadQueue.push({
|
|
fileId : fileEntry.fileId,
|
|
areaTag : fileEntry.areaTag,
|
|
fileName : fileEntry.fileName,
|
|
byteSize : fileEntry.meta.byteSize || 0,
|
|
});
|
|
}
|
|
|
|
isQueued(entryOrId) {
|
|
if(entryOrId instanceof FileEntry) {
|
|
entryOrId = entryOrId.fileId;
|
|
}
|
|
|
|
return this.client.user.downloadQueue.find(e => entryOrId === e.fileId) ? true : false;
|
|
}
|
|
|
|
toProperty() { return JSON.stringify(this.client.user.downloadQueue); }
|
|
|
|
loadFromProperty(prop) {
|
|
try {
|
|
this.client.user.downloadQueue = JSON.parse(prop);
|
|
} catch(e) {
|
|
this.client.user.downloadQueue = [];
|
|
|
|
this.client.log.error( { error : e.message, property : prop }, 'Failed parsing download queue property');
|
|
}
|
|
}
|
|
};
|