mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Adjust update intervals of some extensions
This commit is contained in:
@ -3,7 +3,7 @@ import { getContext, getApiUrl, modules, extension_settings } from "../../extens
|
||||
export { MODULE_NAME };
|
||||
|
||||
const MODULE_NAME = 'expressions';
|
||||
const UPDATE_INTERVAL = 1000;
|
||||
const UPDATE_INTERVAL = 2000;
|
||||
const DEFAULT_EXPRESSIONS = [
|
||||
"admiration",
|
||||
"amusement",
|
||||
|
@ -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);
|
||||
})();
|
@ -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);
|
||||
});
|
Reference in New Issue
Block a user