Clear media alerts from storage on character deletion

This commit is contained in:
Cohee 2025-02-11 20:31:37 +02:00
parent d5bdf1cb90
commit ee101353d8
2 changed files with 10 additions and 0 deletions

View File

@ -9451,6 +9451,9 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {})
continue; continue;
} }
accountStorage.removeItem(`AlertWI_${character.avatar}`);
accountStorage.removeItem(`AlertRegex_${character.avatar}`);
accountStorage.removeItem(`mediaWarningShown:${character.avatar}`);
delete tag_map[character.avatar]; delete tag_map[character.avatar];
select_rm_info('char_delete', character.name); select_rm_info('char_delete', character.name);
@ -11658,6 +11661,9 @@ jQuery(async function () {
eventSource.on(event_types.GROUP_CHAT_DELETED, async (name) => { eventSource.on(event_types.GROUP_CHAT_DELETED, async (name) => {
await deleteItemizedPrompts(name); await deleteItemizedPrompts(name);
}); });
eventSource.on(event_types.CHARACTER_DELETED, async() => {
});
initCustomSelectedSamplers(); initCustomSelectedSamplers();
}); });

View File

@ -105,6 +105,10 @@ class AccountStorage {
console.warn(`AccountStorage not ready (trying to remove ${key})`); console.warn(`AccountStorage not ready (trying to remove ${key})`);
} }
if (!Object.hasOwn(this.state, key)) {
return;
}
delete this.state[key]; delete this.state[key];
saveSettingsDebounced(); saveSettingsDebounced();
} }