fix automatic updater to update only after a certain period

This commit is contained in:
buzz-lightsnack-2007 2024-04-16 19:52:11 +08:00
parent d71e9effd0
commit 423f942cee

View file

@ -2,7 +2,7 @@
This does not stand for "FamiCom" but instead on Finalization and Completion. This script provides installation run scripts. This does not stand for "FamiCom" but instead on Finalization and Completion. This script provides installation run scripts.
*/ */
import { init, read, write } from "./secretariat.js"; import { init, read, write, observe } from "./secretariat.js";
import filters from "./filters.js"; import filters from "./filters.js";
let config = chrome.runtime.getURL("config/config.json"); let config = chrome.runtime.getURL("config/config.json");
@ -32,12 +32,10 @@ export default class fc {
fetch(config) fetch(config)
.then((response) => response.json()) .then((response) => response.json())
.then(async (jsonData) => { .then(async (jsonData) => {
// const secretariat = await import(chrome.runtime.getURL("scripts/secretariat.js"));
let configuration = jsonData; let configuration = jsonData;
// Run the storage initialization. // Run the storage initialization.
// secretariat.init(configuration); init(configuration);
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
@ -85,10 +83,23 @@ export default class fc {
// Provide a way to cancel the interval. // Provide a way to cancel the interval.
let updater_cancel = (updater) => { let updater_cancel = (updater) => {
clearInterval(updater);
}; };
let UPDATER = updater_set();
let updater_interval = async () => {
if ((await read([`settings`, `sync`, `duration`])) ? (await read([`settings`, `sync`, `duration`] * (60 ** 2) * 1000 != DURATION_PREFERENCES[`duration`])) : false) {
DURATION_PREFERENCES[`duration`] = await read([`settings`, `sync`, `duration`]) * (60 ** 2) * 1000;
// Reset the updater.
updater_cancel(UPDATER);
UPDATER = updater_set();
}
};
observe(updater_cancel);
}; };
}) })