Fix eslint + reset level on toggle
| @@ -2949,8 +2949,11 @@ async function getWorldEntry(name, data, entry) { | ||
| 2949 | 2949 | preventRecursionInput.prop('checked', entry.preventRecursion).trigger('input'); |
| 2950 | 2950 | |
| 2951 | 2951 | // delay until recursion |
| 2952 | + // delay until recursion level | |
| 2952 | 2953 | const delayUntilRecursionInput = template.find('input[name="delay_until_recursion"]'); |
| 2953 | 2954 | delayUntilRecursionInput.data('uid', entry.uid); |
| 2955 | + const delayUntilRecursionLevelInput = template.find('input[name="delayUntilRecursionLevel"]'); | |
| 2956 | + delayUntilRecursionLevelInput.data('uid', entry.uid); | |
| 2954 | 2957 | delayUntilRecursionInput.on('input', async function () { |
| 2955 | 2958 | const uid = $(this).data('uid'); |
| 2956 | 2959 | const toggled = $(this).prop('checked'); |
| @@ -2958,15 +2961,13 @@ async function getWorldEntry(name, data, entry) { | ||
| 2958 | 2961 | // If the value contains a number, we'll take that one (set by the level input), otherwise we can use true/false switch |
| 2959 | 2962 | const value = toggled ? data.entries[uid].delayUntilRecursion || true : false; |
| 2960 | 2963 | |
| 2964 | + if (!toggled) delayUntilRecursionLevelInput.val(''); | |
| 2965 | + | |
| 2961 | 2966 | data.entries[uid].delayUntilRecursion = value; |
| 2962 | 2967 | setWIOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion); |
| 2963 | 2968 | await saveWorldInfo(name, data); |
| 2964 | 2969 | }); |
| 2965 | 2970 | 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); | |
| 2970 | 2971 | delayUntilRecursionLevelInput.on('input', async function () { |
| 2971 | 2972 | const uid = $(this).data('uid'); |
| 2972 | 2973 | const content = $(this).val(); |
| @@ -3746,7 +3747,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) { | ||
| 3746 | 3747 | /** @type {number[]} Represents the delay levels for entries that are delayed until recursion */ |
| 3747 | 3748 | const availableRecursionDelayLevels = [...new Set(sortedEntries |
| 3748 | 3749 | .filter(entry => entry.delayUntilRecursion) |
| 3749 | 3750 | .map(entry => entry.delayUntilRecursion === true ? 1 : entry.delayUntilRecursion), |
| 3750 | 3751 | )].sort((a, b) => a - b); |
| 3751 | 3752 | // Already preset with the first level |
| 3752 | 3753 | let currentRecursionDelayLevel = availableRecursionDelayLevels.shift() ?? 0; |
| @@ -3767,7 +3768,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) { | ||
| 3767 | 3768 | count++; |
| 3768 | 3769 | |
| 3769 | 3770 | console.debug(`[WI] --- LOOP #${count} START ---`); |
| 3770 | 3771 | console.debug(`'[WI] Scan state`', Object.entries(scan_state).find(x => x[1] === scanState)); |
| 3771 | 3772 | |
| 3772 | 3773 | // Until decided otherwise, we set the loop to stop scanning after this |
| 3773 | 3774 | let nextScanState = scan_state.NONE; |