Fix eslint + reset level on toggle

984790f53c8d69e5dc5054eb765d2939c9e978c6

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +7 -6Ignore whitespace
public/scripts/world-info.js+7 -6
@@ -2949,8 +2949,11 @@ async function getWorldEntry(name, data, entry) {
29492949 preventRecursionInput.prop('checked', entry.preventRecursion).trigger('input');
29502950
29512951 // delay until recursion
2952+ // delay until recursion level
29522953 const delayUntilRecursionInput = template.find('input[name="delay_until_recursion"]');
29532954 delayUntilRecursionInput.data('uid', entry.uid);
2955+ const delayUntilRecursionLevelInput = template.find('input[name="delayUntilRecursionLevel"]');
2956+ delayUntilRecursionLevelInput.data('uid', entry.uid);
29542957 delayUntilRecursionInput.on('input', async function () {
29552958 const uid = $(this).data('uid');
29562959 const toggled = $(this).prop('checked');
@@ -2958,15 +2961,13 @@ async function getWorldEntry(name, data, entry) {
29582961 // If the value contains a number, we'll take that one (set by the level input), otherwise we can use true/false switch
29592962 const value = toggled ? data.entries[uid].delayUntilRecursion || true : false;
29602963
2964+ if (!toggled) delayUntilRecursionLevelInput.val('');
2965+
29612966 data.entries[uid].delayUntilRecursion = value;
29622967 setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion);
29632968 await saveWorldInfo(name, data);
29642969 });
29652970 delayUntilRecursionInput.prop('checked', entry.delayUntilRecursion).trigger('input');
2966-
2967- // delay until recursion level
2968- const delayUntilRecursionLevelInput = template.find('input[name="delayUntilRecursionLevel"]');
2969- delayUntilRecursionLevelInput.data('uid', entry.uid);
29702971 delayUntilRecursionLevelInput.on('input', async function () {
29712972 const uid = $(this).data('uid');
29722973 const content = $(this).val();
@@ -3746,7 +3747,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
37463747 /** @type {number[]} Represents the delay levels for entries that are delayed until recursion */
37473748 const availableRecursionDelayLevels = [...new Set(sortedEntries
37483749 .filter(entry => entry.delayUntilRecursion)
37493750 .map(entry => entry.delayUntilRecursion === true ? 1 : entry.delayUntilRecursion),
37503751 )].sort((a, b) => a - b);
37513752 // Already preset with the first level
37523753 let currentRecursionDelayLevel = availableRecursionDelayLevels.shift() ?? 0;
@@ -3767,7 +3768,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
37673768 count++;
37683769
37693770 console.debug(`[WI] --- LOOP #${count} START ---`);
37703771 console.debug(`'[WI] Scan state`', Object.entries(scan_state).find(x => x[1] === scanState));
37713772
37723773 // Until decided otherwise, we set the loop to stop scanning after this
37733774 let nextScanState = scan_state.NONE;