Fix type handling of active_character_id

This commit is contained in:
Cohee
2025-02-17 21:00:09 +02:00
parent 434bdab585
commit 0cdc389794

View File

@@ -280,14 +280,13 @@ async function RA_autoloadchat() {
// active character is the name, we should look it up in the character list and get the id // active character is the name, we should look it up in the character list and get the id
if (active_character !== null && active_character !== undefined) { if (active_character !== null && active_character !== undefined) {
const active_character_id = characters.findIndex(x => getTagKeyForEntity(x) === active_character); const active_character_id = characters.findIndex(x => getTagKeyForEntity(x) === active_character);
if (active_character_id !== null) { if (active_character_id !== -1) {
await selectCharacterById(String(active_character_id)); await selectCharacterById(String(active_character_id));
// Do a little tomfoolery to spoof the tag selector // Do a little tomfoolery to spoof the tag selector
const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`); const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`);
applyTagsOnCharacterSelect.call(selectedCharElement); applyTagsOnCharacterSelect.call(selectedCharElement);
} } else {
if (!active_character_id) {
setActiveCharacter(null); setActiveCharacter(null);
saveSettingsDebounced(); saveSettingsDebounced();
console.warn(`Currently active character with ID ${active_character} not found. Resetting to no active character.`); console.warn(`Currently active character with ID ${active_character} not found. Resetting to no active character.`);