Clone WI cache only on get

1e2293713d14d39b630ce1dee8a45393d5346a78

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -4Showing whitespace changes
public/scripts/world-info.js+5 -4
@@ -1,5 +1,5 @@
1import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js';1import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js';
2import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray } from './utils.js';2import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce } from './utils.js';
3import { extension_settings, getContext } from './extensions.js';3import { extension_settings, getContext } from './extensions.js';
4import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';4import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
5import { isMobile } from './RossAscends-mods.js';5import { isMobile } from './RossAscends-mods.js';
@@ -748,7 +748,7 @@ export const wi_anchor_position = {
748};748};
749749
750/** @type {StructuredCloneMap<string,object>} */750/** @type {StructuredCloneMap<string,object>} */
751const worldInfoCache = new StructuredCloneMap();751const worldInfoCache = new StructuredCloneMap({ cloneOnGet: true, cloneOnSet: false });
752752
753/**753/**
754 * Gets the world info based on chat messages.754 * Gets the world info based on chat messages.
@@ -2898,8 +2898,6 @@ function getWorldEntry(name, data, entry) {
2898 .prop('selected', true)2898 .prop('selected', true)
2899 .trigger('input');2899 .trigger('input');
29002900
2901 saveWorldInfo(name, data);
2902
2903 // exclude recursion2901 // exclude recursion
2904 const excludeRecursionInput = template.find('input[name="exclude_recursion"]');2902 const excludeRecursionInput = template.find('input[name="exclude_recursion"]');
2905 excludeRecursionInput.data('uid', entry.uid);2903 excludeRecursionInput.data('uid', entry.uid);
@@ -3269,6 +3267,9 @@ function createWorldInfoEntry(_name, data) {
3269}3267}
32703268
3271async function _save(name, data) {3269async function _save(name, data) {
3270 // Prevent double saving if both immediate and debounced save are called
3271 cancelDebounce(saveWorldDebounced);
3272
3272 await fetch('/api/worldinfo/edit', {3273 await fetch('/api/worldinfo/edit', {
3273 method: 'POST',3274 method: 'POST',
3274 headers: getRequestHeaders(),3275 headers: getRequestHeaders(),