Clear media alerts from storage on character deletion

ee101353d8832bf6f97031f00ccff87b41a623f6

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +10 -0Showing whitespace changes
public/script.js+6 -0
@@ -9451,6 +9451,9 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {})
94519451 continue;
94529452 }
94539453
9454+ accountStorage.removeItem(`AlertWI_${character.avatar}`);
9455+ accountStorage.removeItem(`AlertRegex_${character.avatar}`);
9456+ accountStorage.removeItem(`mediaWarningShown:${character.avatar}`);
94549457 delete tag_map[character.avatar];
94559458 select_rm_info('char_delete', character.name);
94569459
@@ -11658,6 +11661,9 @@ jQuery(async function () {
1165811661 eventSource.on(event_types.GROUP_CHAT_DELETED, async (name) => {
1165911662 await deleteItemizedPrompts(name);
1166011663 });
11664+ eventSource.on(event_types.CHARACTER_DELETED, async() => {
11665+
11666+ });
1166111667
1166211668 initCustomSelectedSamplers();
1166311669});
public/scripts/util/AccountStorage.js+4 -0
@@ -105,6 +105,10 @@ class AccountStorage {
105105 console.warn(`AccountStorage not ready (trying to remove ${key})`);
106106 }
107107
108+ if (!Object.hasOwn(this.state, key)) {
109+ return;
110+ }
111+
108112 delete this.state[key];
109113 saveSettingsDebounced();
110114 }