Loop 3 times before discarding response length override on save
| @@ -574,7 +574,7 @@ export const DEFAULT_SAVE_EDIT_TIMEOUT = debounce_timeout.relaxed; | |||
| 574 | /** @type {debounce_timeout} The debounce timeout used for printing. debounce_timeout.quick: 100 ms */ | 574 | /** @type {debounce_timeout} The debounce timeout used for printing. debounce_timeout.quick: 100 ms */ |
| 575 | export const DEFAULT_PRINT_TIMEOUT = debounce_timeout.quick; | 575 | export const DEFAULT_PRINT_TIMEOUT = debounce_timeout.quick; |
| 576 | 576 | ||
| 577 | export const saveSettingsDebounced = debounce(() => saveSettings(), DEFAULT_SAVE_EDIT_TIMEOUT); | 577 | export const saveSettingsDebounced = debounce((loopCounter = 0) => saveSettings(loopCounter), DEFAULT_SAVE_EDIT_TIMEOUT); |
| 578 | export const saveCharacterDebounced = debounce(() => $('#create_button').trigger('click'), DEFAULT_SAVE_EDIT_TIMEOUT); | 578 | export const saveCharacterDebounced = debounce(() => $('#create_button').trigger('click'), DEFAULT_SAVE_EDIT_TIMEOUT); |
| 579 | 579 | ||
| 580 | /** | 580 | /** |
| @@ -6934,14 +6934,20 @@ function selectKoboldGuiPreset() { | |||
| 6934 | .trigger('change'); | 6934 | .trigger('change'); |
| 6935 | } | 6935 | } |
| 6936 | 6936 | ||
| 6937 | export async function saveSettings(type) { | 6937 | export async function saveSettings(loopCounter = 0) { |
| 6938 | if (!settingsReady) { | 6938 | if (!settingsReady) { |
| 6939 | console.warn('Settings not ready, aborting save'); | 6939 | console.warn('Settings not ready, aborting save'); |
| 6940 | return; | 6940 | return; |
| 6941 | } | 6941 | } |
| 6942 | 6942 | ||
| 6943 | const MAX_RETRIES = 3; | ||
| 6943 | if (TempResponseLength.isCustomized()) { | 6944 | if (TempResponseLength.isCustomized()) { |
| 6944 | console.warn('Response length is currently being overridden. Restoring previous value before saving.'); | 6945 | if (loopCounter < MAX_RETRIES) { |
| 6946 | console.warn('Response length is currently being overridden, scheduling another save'); | ||
| 6947 | saveSettingsDebounced(++loopCounter); | ||
| 6948 | return; | ||
| 6949 | } | ||
| 6950 | console.error('Response length is currently being overridden, but the save loop has reached the maximum number of retries'); | ||
| 6945 | TempResponseLength.restore(null); | 6951 | TempResponseLength.restore(null); |
| 6946 | } | 6952 | } |
| 6947 | 6953 | ||