changed default polling interval to 1.5s;added wrapper function for polling youtube downloads
This commit is contained in:
@@ -11,9 +11,6 @@ export default {
|
|||||||
let container = document.querySelector(tableContainer);
|
let container = document.querySelector(tableContainer);
|
||||||
let currentType = container.getAttribute("type");
|
let currentType = container.getAttribute("type");
|
||||||
let path = basePath + type;
|
let path = basePath + type;
|
||||||
if (type === "youtube-dl") {
|
|
||||||
path = "/apps/ncdownloader/youtube/get";
|
|
||||||
}
|
|
||||||
let name = type + "-downloads";
|
let name = type + "-downloads";
|
||||||
//avoid repeated click
|
//avoid repeated click
|
||||||
if (currentType === name && helper.isPolling()) {
|
if (currentType === name && helper.isPolling()) {
|
||||||
@@ -21,11 +18,15 @@ export default {
|
|||||||
}
|
}
|
||||||
container.setAttribute("type", name);
|
container.setAttribute("type", name);
|
||||||
container.className = "table " + name;
|
container.className = "table " + name;
|
||||||
let delay = 15000;
|
let delay;
|
||||||
if (['active', 'youtube-dl'].includes(type)) {
|
if (!['active', 'youtube-dl'].includes(type)) {
|
||||||
delay = 1500;
|
delay = 15000;
|
||||||
|
}
|
||||||
|
if (type === "youtube-dl") {
|
||||||
|
helper.pollingYoutube();
|
||||||
|
} else {
|
||||||
|
helper.polling(delay, path);
|
||||||
}
|
}
|
||||||
helper.polling(delay, path);
|
|
||||||
};
|
};
|
||||||
eventHandler.add("click", ".waiting-downloads a", event => clickHandler(event, 'waiting'));
|
eventHandler.add("click", ".waiting-downloads a", event => clickHandler(event, 'waiting'));
|
||||||
eventHandler.add("click", ".complete-downloads a", event => clickHandler(event, 'complete'));
|
eventHandler.add("click", ".complete-downloads a", event => clickHandler(event, 'complete'));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ type callback = (...args: any[]) => void
|
|||||||
class Polling {
|
class Polling {
|
||||||
private static instance: Polling;
|
private static instance: Polling;
|
||||||
private timeoutID: number;
|
private timeoutID: number;
|
||||||
private delay: number = 1000;
|
private delay: number = 1500;
|
||||||
private enabled: boolean = false;
|
private enabled: boolean = false;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
@@ -24,7 +24,7 @@ class Polling {
|
|||||||
isEnabled() {
|
isEnabled() {
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
setDelay(time: number): Polling {
|
setDelay(time: number = 1500): Polling {
|
||||||
this.delay = time;
|
this.delay = time;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { translate as t, translatePlural as n } from '@nextcloud/l10n'
|
|||||||
import contentTable from '../lib/contentTable';
|
import contentTable from '../lib/contentTable';
|
||||||
import Http from '../lib/http'
|
import Http from '../lib/http'
|
||||||
import Polling from "../lib/polling";
|
import Polling from "../lib/polling";
|
||||||
|
|
||||||
const helper = {
|
const helper = {
|
||||||
vue: {},
|
vue: {},
|
||||||
addVue(name, object) {
|
addVue(name, object) {
|
||||||
@@ -26,7 +25,7 @@ const helper = {
|
|||||||
disablePolling() {
|
disablePolling() {
|
||||||
Polling.create().disable().clear();
|
Polling.create().disable().clear();
|
||||||
},
|
},
|
||||||
polling(delay = 1000, path) {
|
polling(delay = 1500, path) {
|
||||||
Polling.create().setDelay(delay).run(helper.refresh, path);
|
Polling.create().setDelay(delay).run(helper.refresh, path);
|
||||||
},
|
},
|
||||||
scanFolder(path = "/apps/ncdownloader/scanfolder") {
|
scanFolder(path = "/apps/ncdownloader/scanfolder") {
|
||||||
@@ -37,9 +36,12 @@ const helper = {
|
|||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollingFolder(delay = 1000) {
|
pollingFolder(delay = 1500) {
|
||||||
Polling.create().setDelay(delay).run(helper.scanFolder);
|
Polling.create().setDelay(delay).run(helper.scanFolder);
|
||||||
},
|
},
|
||||||
|
pollingYoutube(delay = 1500) {
|
||||||
|
Polling.create().setDelay(delay).run(helper.refresh, "/apps/ncdownloader/youtube/get");
|
||||||
|
},
|
||||||
refresh(path) {
|
refresh(path) {
|
||||||
path = path || "/apps/ncdownloader/status/active";
|
path = path || "/apps/ncdownloader/status/active";
|
||||||
let url = helper.generateUrl(path);
|
let url = helper.generateUrl(path);
|
||||||
|
|||||||
Reference in New Issue
Block a user