Adjust update intervals of some extensions

This commit is contained in:
Cohee1207
2023-05-03 14:03:57 +03:00
parent b3801ee0e9
commit 1c92fb4b00
3 changed files with 40 additions and 4 deletions

View File

@ -63,6 +63,24 @@ function loadSettings() {
$('#extension_floating_default').val(extension_settings.note.default);
}
let isWorkerBusy = false;
async function moduleWorkerWrapper() {
// Don't touch me I'm busy...
if (isWorkerBusy) {
return;
}
// I'm free. Let's update!
try {
isWorkerBusy = true;
await moduleWorker();
}
finally {
isWorkerBusy = false;
}
}
async function moduleWorker() {
const context = getContext();
@ -147,5 +165,5 @@ async function moduleWorker() {
}
addExtensionsSettings();
setInterval(moduleWorker, UPDATE_INTERVAL);
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL);
})();