ProxmoxAAS-Dashboard/scripts/clientsync.js

26 lines
649 B
JavaScript
Raw Normal View History

2023-07-12 22:37:08 +00:00
import { requestAPI } from "./utils.js";
export async function setupClientSync (scheme, rate, callback) {
if (scheme === "always") {
callback();
window.setInterval(callback, rate);
}
else if (scheme === "hash") {
const newHash = (await requestAPI("/sync/hash")).data;
localStorage.setItem("sync-current-hash", newHash);
callback();
window.setInterval(async () => {
const newHash = (await requestAPI("/sync/hash")).data;
if (localStorage.getItem("sync-current-hash") !== newHash) {
localStorage.setItem("sync-current-hash", newHash);
callback();
}
}, rate);
}
else if (scheme === "interrupt") {
}
else {
}
}