1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update taskbutton Suggested change

This commit is contained in:
grafixeyehero 2019-10-08 20:14:43 +03:00
parent e7570d856f
commit 0e306cad76

View file

@ -73,15 +73,33 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e
}
}
var pollInterval;
var button = options.button;
var serverId = ApiClient.serverId();
function onPollIntervalFired() {
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
pollTasks();
}
}
var pollInterval;
var button = options.button;
var serverId = ApiClient.serverId();
function startInterval() {
var apiClient = connectionManager.getApiClient(serverId);
if (pollInterval) {
clearInterval(pollInterval);
}
apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000");
pollInterval = setInterval(onPollIntervalFired, 5000);
}
function stopInterval() {
connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop");
if (pollInterval) {
clearInterval(pollInterval);
}
}
if (options.panel) {
options.panel.classList.add("hide");
@ -90,29 +108,11 @@ define(["events", "userSettings", "serverNotifications", "connectionManager", "e
if (options.mode == 'off') {
button.removeEventListener("click", onButtonClick);
events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate);
(function () {
connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop");
if (pollInterval) {
clearInterval(pollInterval);
}
})();
stopInterval();
} else {
button.addEventListener("click", onButtonClick);
pollTasks();
(function () {
var apiClient = connectionManager.getApiClient(serverId);
if (pollInterval) {
clearInterval(pollInterval);
}
apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000");
pollInterval = setInterval(onPollIntervalFired, 1e4);
})();
startInterval();
events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate);
}
};