mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Handle aborting status check gracefully
This commit is contained in:
		| @@ -242,6 +242,7 @@ import { INTERACTABLE_CONTROL_CLASS, initKeyboard } from './scripts/keyboard.js' | ||||
| import { initDynamicStyles } from './scripts/dynamic-styles.js'; | ||||
| import { SlashCommandEnumValue, enumTypes } from './scripts/slash-commands/SlashCommandEnumValue.js'; | ||||
| import { commonEnumProviders, enumIcons } from './scripts/slash-commands/SlashCommandCommonEnumsProvider.js'; | ||||
| import { AbortReason } from './scripts/util/AbortReason.js'; | ||||
|  | ||||
| //exporting functions and vars for mods | ||||
| export { | ||||
| @@ -978,8 +979,8 @@ async function fixViewport() { | ||||
|     document.body.style.position = ''; | ||||
| } | ||||
|  | ||||
| function cancelStatusCheck() { | ||||
|     abortStatusCheck?.abort(); | ||||
| function cancelStatusCheck(reason = 'Manually cancelled status check') { | ||||
|     abortStatusCheck?.abort(new AbortReason(reason)); | ||||
|     abortStatusCheck = new AbortController(); | ||||
|     setOnlineStatus('no_connection'); | ||||
| } | ||||
| @@ -1229,7 +1230,12 @@ async function getStatusTextgen() { | ||||
|             toastr.error(data.response, 'API Error', { timeOut: 5000, preventDuplicates: true }); | ||||
|         } | ||||
|     } catch (err) { | ||||
|         console.error('Error getting status', err); | ||||
|         if (err instanceof AbortReason) { | ||||
|             console.info('Status check aborted.', err.reason); | ||||
|         } else { | ||||
|             console.error('Error getting status', err); | ||||
|  | ||||
|         } | ||||
|         setOnlineStatus('no_connection'); | ||||
|     } | ||||
|  | ||||
| @@ -9317,7 +9323,7 @@ jQuery(async function () { | ||||
|         $('#groupCurrentMemberListToggle .inline-drawer-icon').trigger('click'); | ||||
|     }, 200); | ||||
|  | ||||
|     $(document).on('click', '.api_loading', cancelStatusCheck); | ||||
|     $(document).on('click', '.api_loading', () => cancelStatusCheck('Canceled because connecting was manually canceled')); | ||||
|  | ||||
|     //////////INPUT BAR FOCUS-KEEPING LOGIC///////////// | ||||
|     let S_TAPreviouslyFocused = false; | ||||
| @@ -10076,7 +10082,7 @@ jQuery(async function () { | ||||
|     }); | ||||
|  | ||||
|     $('#main_api').change(function () { | ||||
|         cancelStatusCheck(); | ||||
|         cancelStatusCheck("Canceled because main api changed"); | ||||
|         changeMainAPI(); | ||||
|         saveSettingsDebounced(); | ||||
|     }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user