Get rid of isSaveWorldInfoDisabled
| @@ -86,7 +86,6 @@ const saveSettingsDebounced = debounce(() => { | ||
| 86 | 86 | }, debounce_timeout.relaxed); |
| 87 | 87 | const sortFn = (a, b) => b.order - a.order; |
| 88 | 88 | let updateEditor = (navigation, flashOnNav = true) => { console.debug('Triggered WI navigation', navigation, flashOnNav); }; |
| 89 | -let isSaveWorldInfoDisabled = false; | |
| 90 | 89 | |
| 91 | 90 | // Do not optimize. updateEditor is a function that is updated by the displayWorldEntries with new data. |
| 92 | 91 | export const worldInfoFilter = new FilterHelper(() => updateEditor()); |
| @@ -2102,8 +2101,6 @@ async function displayWorldEntries(name, data, navigation = navigation_option.no | ||
| 2102 | 2101 | showNavigator: true, |
| 2103 | 2102 | callback: async function (/** @type {object[]} */ page) { |
| 2104 | 2103 | try { |
| 2105 | - // Prevent saveWorldInfo from firing timeouts while rendering the list | |
| 2106 | - isSaveWorldInfoDisabled = true; | |
| 2107 | 2104 | clearEntryList(worldEntriesList); |
| 2108 | 2105 | |
| 2109 | 2106 | const keywordHeaders = await renderTemplateAsync('worldInfoKeywordHeaders'); |
| @@ -2131,8 +2128,6 @@ async function displayWorldEntries(name, data, navigation = navigation_option.no | ||
| 2131 | 2128 | worldEntriesList.append(blocks); |
| 2132 | 2129 | } catch (error) { |
| 2133 | 2130 | console.error('Error while rendering WI entries:', error); |
| 2134 | - } finally { | |
| 2135 | - isSaveWorldInfoDisabled = false; | |
| 2136 | 2131 | } |
| 2137 | 2132 | }, |
| 2138 | 2133 | afterSizeSelectorChange: function (e) { |
| @@ -2635,14 +2630,14 @@ function handleMatchCheckboxHelper({ template, entry, fieldName, data, name }) { | ||
| 2635 | 2630 | const key = originalWIDataKeyMap[fieldName]; |
| 2636 | 2631 | const checkBoxElem = template.find(`input[type="checkbox"][name="${fieldName}"]`); |
| 2637 | 2632 | checkBoxElem.data('uid', entry.uid); |
| 2638 | 2633 | checkBoxElem.on('input', async function (_, { noSave = false } = {}) { |
| 2639 | 2634 | const uid = $(this).data('uid'); |
| 2640 | 2635 | const value = $(this).prop('checked'); |
| 2641 | 2636 | data.entries[uid][fieldName] = value; |
| 2642 | 2637 | setWIOriginalDataValue(data, uid, key, data.entries[uid][fieldName]); |
| 2643 | 2638 | !noSave && await saveWorldInfo(name, data); |
| 2644 | 2639 | }); |
| 2645 | 2640 | checkBoxElem.prop('checked', !!entry[fieldName]).trigger('input', { noSave: true }); |
| 2646 | 2641 | } |
| 2647 | 2642 | |
| 2648 | 2643 | /** |
| @@ -2736,7 +2731,7 @@ function handleCharacterFilterChangeHelper({ characterFilter, data, entry, name, | ||
| 2736 | 2731 | */ |
| 2737 | 2732 | function handleProbabilityInputHelper({ probabilityInput, data, entry, name, setWIOriginalDataValue, saveWorldInfo }) { |
| 2738 | 2733 | probabilityInput.data('uid', entry.uid); |
| 2739 | 2734 | probabilityInput.on('input', async function (_, { noSave = false } = {}) { |
| 2740 | 2735 | const uid = $(this).data('uid'); |
| 2741 | 2736 | const value = Number($(this).val()); |
| 2742 | 2737 | data.entries[uid].probability = !isNaN(value) ? value : null; |
| @@ -2747,9 +2742,9 @@ function handleProbabilityInputHelper({ probabilityInput, data, entry, name, set | ||
| 2747 | 2742 | } |
| 2748 | 2743 | } |
| 2749 | 2744 | setWIOriginalDataValue(data, uid, 'extensions.probability', data.entries[uid].probability); |
| 2750 | 2745 | !noSave && await saveWorldInfo(name, data); |
| 2751 | 2746 | }); |
| 2752 | 2747 | probabilityInput.val(entry.probability).trigger('input', { noSave: true }); |
| 2753 | 2748 | probabilityInput.css('width', 'calc(3em + 15px)'); |
| 2754 | 2749 | } |
| 2755 | 2750 | |
| @@ -2758,12 +2753,12 @@ function handleProbabilityInputHelper({ probabilityInput, data, entry, name, set | ||
| 2758 | 2753 | */ |
| 2759 | 2754 | function handleProbabilityToggleHelper({ probabilityToggle, data, entry, name, probabilityInput, setWIOriginalDataValue, saveWorldInfo }) { |
| 2760 | 2755 | probabilityToggle.data('uid', entry.uid); |
| 2761 | 2756 | probabilityToggle.on('input', async function (_, { noSave = false } = {}) { |
| 2762 | 2757 | const uid = $(this).data('uid'); |
| 2763 | 2758 | const value = $(this).prop('checked'); |
| 2764 | 2759 | data.entries[uid].useProbability = value; |
| 2765 | 2760 | const probabilityContainer = $(this).closest('.world_entry').find('.probabilityContainer'); |
| 2766 | 2761 | !noSave && await saveWorldInfo(name, data); |
| 2767 | 2762 | value ? probabilityContainer.show() : probabilityContainer.hide(); |
| 2768 | 2763 | if (value && data.entries[uid].probability === null) { |
| 2769 | 2764 | data.entries[uid].probability = 100; |
| @@ -2771,9 +2766,9 @@ function handleProbabilityToggleHelper({ probabilityToggle, data, entry, name, p | ||
| 2771 | 2766 | if (!value) { |
| 2772 | 2767 | data.entries[uid].probability = null; |
| 2773 | 2768 | } |
| 2774 | 2769 | probabilityInput.val(data.entries[uid].probability).trigger('input', { noSave }); |
| 2775 | 2770 | }); |
| 2776 | 2771 | probabilityToggle.prop('checked', true).trigger('input', { noSave: true }); |
| 2777 | 2772 | probabilityToggle.parent().hide(); |
| 2778 | 2773 | } |
| 2779 | 2774 | |
| @@ -2782,14 +2777,14 @@ function handleProbabilityToggleHelper({ probabilityToggle, data, entry, name, p | ||
| 2782 | 2777 | */ |
| 2783 | 2778 | function handleBooleanSelectHelper({ selectElem, entry, entryKey, data, name, setWIOriginalDataValue, saveWorldInfo }) { |
| 2784 | 2779 | selectElem.data('uid', entry.uid); |
| 2785 | 2780 | selectElem.on('input', async function (_, { noSave = false } = {}) { |
| 2786 | 2781 | const uid = $(this).data('uid'); |
| 2787 | 2782 | const value = $(this).val(); |
| 2788 | 2783 | data.entries[uid][entryKey] = value === 'null' ? null : value === 'true'; |
| 2789 | 2784 | setWIOriginalDataValue(data, uid, `extensions.${entryKey.replace(/[A-Z]/g, m => `_${m.toLowerCase()}`)}`, data.entries[uid][entryKey]); |
| 2790 | 2785 | !noSave && await saveWorldInfo(name, data); |
| 2791 | 2786 | }); |
| 2792 | 2787 | selectElem.val((entry[entryKey] === null || entry[entryKey] === undefined) ? 'null' : entry[entryKey] ? 'true' : 'false').trigger('input', { noSave: true }); |
| 2793 | 2788 | } |
| 2794 | 2789 | |
| 2795 | 2790 | /** |
| @@ -2797,7 +2792,7 @@ function handleBooleanSelectHelper({ selectElem, entry, entryKey, data, name, se | ||
| 2797 | 2792 | */ |
| 2798 | 2793 | function handleNumberInputHelper({ inputElem, entry, entryKey, data, name, setWIOriginalDataValue, saveWorldInfo, min, max, clamp = false }) { |
| 2799 | 2794 | inputElem.data('uid', entry.uid); |
| 2800 | 2795 | inputElem.on('input', async function (_, { noSave = false } = {}) { |
| 2801 | 2796 | const uid = $(this).data('uid'); |
| 2802 | 2797 | let value = Number($(this).val()); |
| 2803 | 2798 | if (clamp) { |
| @@ -2811,9 +2806,9 @@ function handleNumberInputHelper({ inputElem, entry, entryKey, data, name, setWI | ||
| 2811 | 2806 | } |
| 2812 | 2807 | data.entries[uid][entryKey] = !isNaN(value) ? value : null; |
| 2813 | 2808 | setWIOriginalDataValue(data, uid, `extensions.${entryKey.replace(/[A-Z]/g, m => `_${m.toLowerCase()}`)}`, data.entries[uid][entryKey]); |
| 2814 | 2809 | !noSave && await saveWorldInfo(name, data); |
| 2815 | 2810 | }); |
| 2816 | 2811 | inputElem.val(entry[entryKey] ?? (clamp ? min : '')).trigger('input', { noSave: true }); |
| 2817 | 2812 | } |
| 2818 | 2813 | |
| 2819 | 2814 | /** |
| @@ -2824,7 +2819,7 @@ function handleEntryStateSelectorHelper({ entryStateSelector, entry, data, name, | ||
| 2824 | 2819 | entryStateSelector.on('click', function (event) { |
| 2825 | 2820 | event.stopPropagation(); |
| 2826 | 2821 | }); |
| 2827 | 2822 | entryStateSelector.on('input', async function (_, { noSave = false } = {}) { |
| 2828 | 2823 | const uid = entry.uid; |
| 2829 | 2824 | const value = $(this).val(); |
| 2830 | 2825 | switch (value) { |
| @@ -2847,10 +2842,10 @@ function handleEntryStateSelectorHelper({ entryStateSelector, entry, data, name, | ||
| 2847 | 2842 | setWIOriginalDataValue(data, uid, 'extensions.vectorized', true); |
| 2848 | 2843 | break; |
| 2849 | 2844 | } |
| 2850 | 2845 | !noSave && await saveWorldInfo(name, data); |
| 2851 | 2846 | }); |
| 2852 | 2847 | const entryState = () => entry.constant === true ? 'constant' : entry.vectorized === true ? 'vectorized' : 'normal'; |
| 2853 | 2848 | entryStateSelector.find(`option[value=${entryState()}]`).prop('selected', true).trigger('input', { noSave: true }); |
| 2854 | 2849 | } |
| 2855 | 2850 | |
| 2856 | 2851 | /** |
| @@ -2892,28 +2887,28 @@ export async function getWorldEntry(name, data, entry) { | ||
| 2892 | 2887 | // Comment |
| 2893 | 2888 | const commentInput = headerTemplate.find('textarea[name="comment"]'); |
| 2894 | 2889 | commentInput.data('uid', entry.uid); |
| 2895 | 2890 | commentInput.on('input', async function (_, { skipReset = false, noSave = false } = {}) { |
| 2896 | 2891 | const uid = $(this).data('uid'); |
| 2897 | 2892 | const value = $(this).val(); |
| 2898 | 2893 | !skipReset && await resetScrollHeight(this); |
| 2899 | 2894 | data.entries[uid].comment = value; |
| 2900 | 2895 | setWIOriginalDataValue(data, uid, 'comment', data.entries[uid].comment); |
| 2901 | 2896 | !noSave && await saveWorldInfo(name, data); |
| 2902 | 2897 | }); |
| 2903 | 2898 | commentInput.val(entry.comment).trigger('input', { skipReset: true, noSave: true }); |
| 2904 | 2899 | |
| 2905 | 2900 | // Order |
| 2906 | 2901 | const orderInput = headerTemplate.find('input[name="order"]'); |
| 2907 | 2902 | orderInput.data('uid', entry.uid); |
| 2908 | 2903 | orderInput.on('input', async function (_, { noSave = false } = {}) { |
| 2909 | 2904 | const uid = $(this).data('uid'); |
| 2910 | 2905 | const value = Number($(this).val()); |
| 2911 | 2906 | data.entries[uid].order = !isNaN(value) ? value : 0; |
| 2912 | 2907 | updatePosOrdDisplayHelper({ template: headerTemplate, data, uid }); |
| 2913 | 2908 | setWIOriginalDataValue(data, uid, 'insertion_order', data.entries[uid].order); |
| 2914 | 2909 | !noSave && await saveWorldInfo(name, data); |
| 2915 | 2910 | }); |
| 2916 | 2911 | orderInput.val(entry.order).trigger('input', { noSave: true }); |
| 2917 | 2912 | orderInput.css('width', 'calc(3em + 15px)'); |
| 2918 | 2913 | |
| 2919 | 2914 | // Probability |
| @@ -2932,7 +2927,7 @@ export async function getWorldEntry(name, data, entry) { | ||
| 2932 | 2927 | const positionInput = headerTemplate.find('select[name="position"]'); |
| 2933 | 2928 | positionInput.data('uid', entry.uid); |
| 2934 | 2929 | positionInput.on('click', e => e.stopPropagation()); |
| 2935 | 2930 | positionInput.on('input', async function (_, { noSave = false } = {}) { |
| 2936 | 2931 | const uid = $(this).data('uid'); |
| 2937 | 2932 | const value = Number($(this).val()); |
| 2938 | 2933 | data.entries[uid].position = !isNaN(value) ? value : 0; |
| @@ -2951,10 +2946,10 @@ export async function getWorldEntry(name, data, entry) { | ||
| 2951 | 2946 | setWIOriginalDataValue(data, uid, 'position', data.entries[uid].position == 0 ? 'before_char' : 'after_char'); |
| 2952 | 2947 | setWIOriginalDataValue(data, uid, 'extensions.position', data.entries[uid].position); |
| 2953 | 2948 | setWIOriginalDataValue(data, uid, 'extensions.role', data.entries[uid].role); |
| 2954 | 2949 | !noSave && await saveWorldInfo(name, data); |
| 2955 | 2950 | }); |
| 2956 | 2951 | const roleValue = entry.position === world_info_position.atDepth ? String(entry.role ?? extension_prompt_roles.SYSTEM) : ''; |
| 2957 | 2952 | headerTemplate.find(`select[name="position"] option[value="${entry.position}"][data-role="${roleValue}"]`).prop('selected', true).trigger('input', { noSave: true }); |
| 2958 | 2953 | |
| 2959 | 2954 | // Tri-state selector |
| 2960 | 2955 | handleEntryStateSelectorHelper({ |
| @@ -3098,39 +3093,39 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3098 | 3093 | // Comment toggle |
| 3099 | 3094 | const commentToggle = editTemplate.find('input[name="addMemo"]'); |
| 3100 | 3095 | commentToggle.data('uid', entry.uid); |
| 3101 | 3096 | commentToggle.on('input', async function (_, { noSave = false } = {}) { |
| 3102 | 3097 | const uid = $(this).data('uid'); |
| 3103 | 3098 | const value = $(this).prop('checked'); |
| 3104 | 3099 | const commentContainer = $(this).closest('.world_entry').find('.commentContainer'); |
| 3105 | 3100 | data.entries[uid].addMemo = value; |
| 3106 | 3101 | !noSave && await saveWorldInfo(name, data); |
| 3107 | 3102 | value ? commentContainer.show() : commentContainer.hide(); |
| 3108 | 3103 | }); |
| 3109 | 3104 | commentToggle.prop('checked', true).trigger('input', { noSave: true }); |
| 3110 | 3105 | commentToggle.parent().hide(); |
| 3111 | 3106 | |
| 3112 | 3107 | // Logic AND/NOT |
| 3113 | 3108 | const selectiveLogicDropdown = editTemplate.find('select[name="entryLogicType"]'); |
| 3114 | 3109 | selectiveLogicDropdown.data('uid', entry.uid); |
| 3115 | 3110 | selectiveLogicDropdown.on('click', e => e.stopPropagation()); |
| 3116 | 3111 | selectiveLogicDropdown.on('input', async function (_, { noSave = false } = {}) { |
| 3117 | 3112 | const uid = $(this).data('uid'); |
| 3118 | 3113 | const value = Number($(this).val()); |
| 3119 | 3114 | data.entries[uid].selectiveLogic = !isNaN(value) ? value : world_info_logic.AND_ANY; |
| 3120 | 3115 | setWIOriginalDataValue(data, uid, 'selectiveLogic', data.entries[uid].selectiveLogic); |
| 3121 | 3116 | !noSave && await saveWorldInfo(name, data); |
| 3122 | 3117 | }); |
| 3123 | 3118 | editTemplate.find(`select[name="entryLogicType"] option[value=${entry.selectiveLogic}]`).prop('selected', true).trigger('input', { noSave: true }); |
| 3124 | 3119 | |
| 3125 | 3120 | // Selective |
| 3126 | 3121 | const selectiveInput = editTemplate.find('input[name="selective"]'); |
| 3127 | 3122 | selectiveInput.data('uid', entry.uid); |
| 3128 | 3123 | selectiveInput.on('input', async function (_, { noSave = false } = {}) { |
| 3129 | 3124 | const uid = $(this).data('uid'); |
| 3130 | 3125 | const value = $(this).prop('checked'); |
| 3131 | 3126 | data.entries[uid].selective = value; |
| 3132 | 3127 | setWIOriginalDataValue(data, uid, 'selective', data.entries[uid].selective); |
| 3133 | 3128 | !noSave && await saveWorldInfo(name, data); |
| 3134 | 3129 | const keysecondary = $(this).closest('.world_entry').find('.keysecondary'); |
| 3135 | 3130 | const keysecondarytextpole = $(this).closest('.world_entry').find('.keysecondarytextpole'); |
| 3136 | 3131 | const keyprimaryselect = $(this).closest('.world_entry').find('.keyprimaryselect'); |
| @@ -3138,7 +3133,7 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3138 | 3133 | keysecondarytextpole.css('height', keyprimaryHeight + 'px'); |
| 3139 | 3134 | value ? keysecondary.show() : keysecondary.hide(); |
| 3140 | 3135 | }); |
| 3141 | 3136 | selectiveInput.prop('checked', true).trigger('input', { noSave: true }); |
| 3142 | 3137 | selectiveInput.parent().hide(); |
| 3143 | 3138 | |
| 3144 | 3139 | // Character filter |
| @@ -3146,7 +3141,7 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3146 | 3141 | characterFilterLabel.text(entry.characterFilter?.isExclude ? 'Exclude Character(s)' : 'Filter to Character(s)'); |
| 3147 | 3142 | const characterExclusionInput = editTemplate.find('input[name="character_exclusion"]'); |
| 3148 | 3143 | characterExclusionInput.data('uid', entry.uid); |
| 3149 | 3144 | characterExclusionInput.on('input', async function (_, { noSave = false } = {}) { |
| 3150 | 3145 | const uid = $(this).data('uid'); |
| 3151 | 3146 | const value = $(this).prop('checked'); |
| 3152 | 3147 | characterFilterLabel.text(value ? 'Exclude Character(s)' : 'Filter to Character(s)'); |
| @@ -3167,9 +3162,9 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3167 | 3162 | } |
| 3168 | 3163 | } |
| 3169 | 3164 | setWIOriginalDataValue(data, uid, 'character_filter', data.entries[uid].characterFilter); |
| 3170 | 3165 | !noSave && await saveWorldInfo(name, data); |
| 3171 | 3166 | }); |
| 3172 | 3167 | characterExclusionInput.prop('checked', entry.characterFilter?.isExclude ?? false).trigger('input', { noSave: true }); |
| 3173 | 3168 | |
| 3174 | 3169 | const characterFilter = editTemplate.find('select[name="characterFilter"]'); |
| 3175 | 3170 | characterFilter.data('uid', entry.uid); |
| @@ -3189,21 +3184,21 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3189 | 3184 | const contentInput = editTemplate.find('textarea[name="content"]'); |
| 3190 | 3185 | contentInput.data('uid', entry.uid); |
| 3191 | 3186 | contentInput.attr('id', contentInputId); |
| 3192 | 3187 | contentInput.on('input', async function (_, { skipCount, noSave } = {}) { |
| 3193 | 3188 | const uid = $(this).data('uid'); |
| 3194 | 3189 | const value = $(this).val(); |
| 3195 | 3190 | data.entries[uid].content = value; |
| 3196 | 3191 | setWIOriginalDataValue(data, uid, 'content', data.entries[uid].content); |
| 3197 | 3192 | !noSave && await saveWorldInfo(name, data); |
| 3198 | 3193 | if (!skipCount) countTokensDebounced(counter, value); |
| 3199 | 3194 | }); |
| 3200 | 3195 | contentInput.val(entry.content).trigger('input', { skipCount: true, noSave: true }); |
| 3201 | 3196 | editTemplate.find('.editor_maximize').attr('data-for', contentInputId); |
| 3202 | 3197 | |
| 3203 | 3198 | // Scan depth |
| 3204 | 3199 | const scanDepthInput = editTemplate.find('input[name="scanDepth"]'); |
| 3205 | 3200 | scanDepthInput.data('uid', entry.uid); |
| 3206 | 3201 | scanDepthInput.on('input', async function (_, { noSave = false } = {}) { |
| 3207 | 3202 | const uid = $(this).data('uid'); |
| 3208 | 3203 | const isEmpty = $(this).val() === ''; |
| 3209 | 3204 | const value = Number($(this).val()); |
| @@ -3219,34 +3214,34 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3219 | 3214 | } |
| 3220 | 3215 | data.entries[uid].scanDepth = !isEmpty && !isNaN(value) && value >= 0 && value <= MAX_SCAN_DEPTH ? Math.floor(value) : null; |
| 3221 | 3216 | setWIOriginalDataValue(data, uid, 'extensions.scan_depth', data.entries[uid].scanDepth); |
| 3222 | 3217 | !noSave && await saveWorldInfo(name, data); |
| 3223 | 3218 | }); |
| 3224 | 3219 | scanDepthInput.val(entry.scanDepth ?? null).trigger('input', { noSave: true }); |
| 3225 | 3220 | |
| 3226 | 3221 | // Group |
| 3227 | 3222 | const groupInput = editTemplate.find('input[name="group"]'); |
| 3228 | 3223 | groupInput.data('uid', entry.uid); |
| 3229 | 3224 | groupInput.on('input', async function (_, { noSave = false } = {}) { |
| 3230 | 3225 | const uid = $(this).data('uid'); |
| 3231 | 3226 | const value = String($(this).val()).trim(); |
| 3232 | 3227 | data.entries[uid].group = value; |
| 3233 | 3228 | setWIOriginalDataValue(data, uid, 'extensions.group', data.entries[uid].group); |
| 3234 | 3229 | !noSave && await saveWorldInfo(name, data); |
| 3235 | 3230 | }); |
| 3236 | 3231 | groupInput.val(entry.group ?? '').trigger('input', { noSave: true }); |
| 3237 | 3232 | setTimeout(() => createEntryInputAutocomplete(groupInput, getInclusionGroupCallback(data), { allowMultiple: true }), 1); |
| 3238 | 3233 | |
| 3239 | 3234 | // Inclusion priority |
| 3240 | 3235 | const groupOverrideInput = editTemplate.find('input[name="groupOverride"]'); |
| 3241 | 3236 | groupOverrideInput.data('uid', entry.uid); |
| 3242 | 3237 | groupOverrideInput.on('input', async function (_, { noSave = false } = {}) { |
| 3243 | 3238 | const uid = $(this).data('uid'); |
| 3244 | 3239 | const value = $(this).prop('checked'); |
| 3245 | 3240 | data.entries[uid].groupOverride = value; |
| 3246 | 3241 | setWIOriginalDataValue(data, uid, 'extensions.group_override', data.entries[uid].groupOverride); |
| 3247 | 3242 | !noSave && await saveWorldInfo(name, data); |
| 3248 | 3243 | }); |
| 3249 | 3244 | groupOverrideInput.prop('checked', entry.groupOverride).trigger('input', { noSave: true }); |
| 3250 | 3245 | |
| 3251 | 3246 | // Group weight |
| 3252 | 3247 | handleNumberInputHelper({ |
| @@ -3281,17 +3276,17 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3281 | 3276 | delayUntilRecursionInput.data('uid', entry.uid); |
| 3282 | 3277 | const delayUntilRecursionLevelInput = editTemplate.find('input[name="delayUntilRecursionLevel"]'); |
| 3283 | 3278 | delayUntilRecursionLevelInput.data('uid', entry.uid); |
| 3284 | 3279 | delayUntilRecursionInput.on('input', async function (_, { noSave = false } = {}) { |
| 3285 | 3280 | const uid = $(this).data('uid'); |
| 3286 | 3281 | const toggled = $(this).prop('checked'); |
| 3287 | 3282 | const value = toggled ? data.entries[uid].delayUntilRecursion || true : false; |
| 3288 | 3283 | if (!toggled) delayUntilRecursionLevelInput.val(''); |
| 3289 | 3284 | data.entries[uid].delayUntilRecursion = value; |
| 3290 | 3285 | setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion); |
| 3291 | 3286 | !noSave && await saveWorldInfo(name, data); |
| 3292 | 3287 | }); |
| 3293 | 3288 | delayUntilRecursionInput.prop('checked', entry.delayUntilRecursion).trigger('input', { noSave: true }); |
| 3294 | 3289 | delayUntilRecursionLevelInput.on('input', async function (_, { noSave = false } = {}) { |
| 3295 | 3290 | const uid = $(this).data('uid'); |
| 3296 | 3291 | const content = $(this).val(); |
| 3297 | 3292 | const value = content === '' ? (typeof data.entries[uid].delayUntilRecursion === 'boolean' ? data.entries[uid].delayUntilRecursion : true) |
| @@ -3300,9 +3295,9 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3300 | 3295 | : false; |
| 3301 | 3296 | data.entries[uid].delayUntilRecursion = value; |
| 3302 | 3297 | setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion); |
| 3303 | 3298 | !noSave && await saveWorldInfo(name, data); |
| 3304 | 3299 | }); |
| 3305 | 3300 | delayUntilRecursionLevelInput.val(['number', 'string'].includes(typeof entry.delayUntilRecursion) ? entry.delayUntilRecursion : '').trigger('input', { noSave: true }); |
| 3306 | 3301 | |
| 3307 | 3302 | // Boolean selects |
| 3308 | 3303 | handleBooleanSelectHelper({ |
| @@ -3329,14 +3324,14 @@ export async function getWorldEntry(name, data, entry) { | ||
| 3329 | 3324 | // Automation ID |
| 3330 | 3325 | const automationIdInput = editTemplate.find('input[name="automationId"]'); |
| 3331 | 3326 | automationIdInput.data('uid', entry.uid); |
| 3332 | 3327 | automationIdInput.on('input', async function (_, { noSave = false } = {}) { |
| 3333 | 3328 | const uid = $(this).data('uid'); |
| 3334 | 3329 | const value = $(this).val(); |
| 3335 | 3330 | data.entries[uid].automationId = value; |
| 3336 | 3331 | setWIOriginalDataValue(data, uid, 'extensions.automation_id', data.entries[uid].automationId); |
| 3337 | 3332 | !noSave && await saveWorldInfo(name, data); |
| 3338 | 3333 | }); |
| 3339 | 3334 | automationIdInput.val(entry.automationId ?? '').trigger('input', { noSave: true }); |
| 3340 | 3335 | setTimeout(() => createEntryInputAutocomplete(automationIdInput, getAutomationIdCallback(data)), 1); |
| 3341 | 3336 | |
| 3342 | 3337 | countTokensDebounced(counter, contentInput.val()); |
| @@ -3588,11 +3583,6 @@ async function _save(name, data) { | ||
| 3588 | 3583 | * @return {Promise<void>} A promise that resolves when the world info is saved |
| 3589 | 3584 | */ |
| 3590 | 3585 | export async function saveWorldInfo(name, data, immediately = false) { |
| 3591 | - // Saving is temporarily disabled | |
| 3592 | - if (isSaveWorldInfoDisabled) { | |
| 3593 | - return; | |
| 3594 | - } | |
| 3595 | - | |
| 3596 | 3586 | if (!name || !data) { |
| 3597 | 3587 | return; |
| 3598 | 3588 | } |