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

@@ -4,7 +4,7 @@ import { extension_prompt_types, is_send_press, saveSettingsDebounced } from "..
export { MODULE_NAME };
const MODULE_NAME = '1_memory';
const UPDATE_INTERVAL = 1000;
const UPDATE_INTERVAL = 5000;
let lastCharacterId = null;
let lastGroupId = null;
@@ -129,6 +129,24 @@ function getLatestMemoryFromChat(chat) {
return '';
}
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();
const chat = context.chat;
@@ -366,5 +384,5 @@ $(document).ready(function () {
addExtensionControls();
loadSettings();
setInterval(moduleWorker, UPDATE_INTERVAL);
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL);
});