| 280 | // active character is the name, we should look it up in the character list and get the id | 280 | // active character is the name, we should look it up in the character list and get the id |
| 281 | if (active_character !== null && active_character !== undefined) { | 281 | if (active_character !== null && active_character !== undefined) { |
| 282 | const active_character_id = characters.findIndex(x => getTagKeyForEntity(x) === active_character); | 282 | const active_character_id = characters.findIndex(x => getTagKeyForEntity(x) === active_character); |
| 283 | if (active_character_id !== null) { | 283 | if (active_character_id !== -1) { |
| 284 | await selectCharacterById(String(active_character_id)); | 284 | await selectCharacterById(String(active_character_id)); |
| 285 | | 285 | |
| 286 | // Do a little tomfoolery to spoof the tag selector | 286 | // Do a little tomfoolery to spoof the tag selector |
| 287 | const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`); | 287 | const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`); |
| 288 | applyTagsOnCharacterSelect.call(selectedCharElement); | 288 | applyTagsOnCharacterSelect.call(selectedCharElement); |
| 289 | } | 289 | } else { |
| 290 | if (!active_character_id) { | | |
| 291 | setActiveCharacter(null); | 290 | setActiveCharacter(null); |
| 292 | saveSettingsDebounced(); | 291 | saveSettingsDebounced(); |
| 293 | console.warn(`Currently active character with ID ${active_character} not found. Resetting to no active character.`); | 292 | console.warn(`Currently active character with ID ${active_character} not found. Resetting to no active character.`); |