Suppress error messages when Firefox unloads the tab (#5013) * Fix error messages when Firefox tab reopened after unload #4989 * Export settingsReady flag
Signed| @@ -388,7 +388,7 @@ let chatSaveTimeout; | ||
| 388 | 388 | let importFlashTimeout; |
| 389 | 389 | export let isChatSaving = false; |
| 390 | 390 | let firstRun = false; |
| 391 | 391 | export let settingsReady = false; |
| 392 | 392 | let currentVersion = '0.0.0'; |
| 393 | 393 | export let displayVersion = 'SillyTavern'; |
| 394 | 394 | |
| @@ -9463,6 +9463,11 @@ function addAlternateGreeting(template, greeting, index, getArray, popup) { | ||
| 9463 | 9463 | * @param {Event} [e] Event that triggered the function call. |
| 9464 | 9464 | */ |
| 9465 | 9465 | export async function createOrEditCharacter(e) { |
| 9466 | + if (!settingsReady) { | |
| 9467 | + console.warn('Settings not ready, aborting character creation/editing.'); | |
| 9468 | + return; | |
| 9469 | + } | |
| 9470 | + | |
| 9466 | 9471 | $('#rm_info_avatar').html(''); |
| 9467 | 9472 | const formData = new FormData(/** @type {HTMLFormElement} */($('#form_create').get(0))); |
| 9468 | 9473 | formData.set('fav', String(fav_ch_checked)); |
| @@ -30,6 +30,7 @@ import { | ||
| 30 | 30 | extension_prompt_types, |
| 31 | 31 | extension_prompt_roles, |
| 32 | 32 | deleteMessage, |
| 33 | + settingsReady, | |
| 33 | 34 | } from '../script.js'; |
| 34 | 35 | import { isMobile, initMovingUI, favsToHotswap } from './RossAscends-mods.js'; |
| 35 | 36 | import { |
| @@ -4016,6 +4017,11 @@ jQuery(() => { | ||
| 4016 | 4017 | power_user.experimental_macro_engine = !!$(this).prop('checked'); |
| 4017 | 4018 | saveSettingsDebounced(); |
| 4018 | 4019 | |
| 4020 | + // Check if the app is ready before showing the toast | |
| 4021 | + if (!settingsReady) { | |
| 4022 | + return; | |
| 4023 | + } | |
| 4024 | + | |
| 4019 | 4025 | eventSource.once(event_types.SETTINGS_UPDATED, function() { |
| 4020 | 4026 | toastr.warning( |
| 4021 | 4027 | t`Click here to reload.`, |