From ee101353d8832bf6f97031f00ccff87b41a623f6 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 11 Feb 2025 20:31:37 +0200 Subject: [PATCH] Clear media alerts from storage on character deletion --- public/script.js | 6 ++++++ public/scripts/util/AccountStorage.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/public/script.js b/public/script.js index ca0d0f885..28d7c7b1c 100644 --- a/public/script.js +++ b/public/script.js @@ -9451,6 +9451,9 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {}) continue; } + accountStorage.removeItem(`AlertWI_${character.avatar}`); + accountStorage.removeItem(`AlertRegex_${character.avatar}`); + accountStorage.removeItem(`mediaWarningShown:${character.avatar}`); delete tag_map[character.avatar]; select_rm_info('char_delete', character.name); @@ -11658,6 +11661,9 @@ jQuery(async function () { eventSource.on(event_types.GROUP_CHAT_DELETED, async (name) => { await deleteItemizedPrompts(name); }); + eventSource.on(event_types.CHARACTER_DELETED, async() => { + + }); initCustomSelectedSamplers(); }); diff --git a/public/scripts/util/AccountStorage.js b/public/scripts/util/AccountStorage.js index fe163813d..e2f35d074 100644 --- a/public/scripts/util/AccountStorage.js +++ b/public/scripts/util/AccountStorage.js @@ -105,6 +105,10 @@ class AccountStorage { console.warn(`AccountStorage not ready (trying to remove ${key})`); } + if (!Object.hasOwn(this.state, key)) { + return; + } + delete this.state[key]; saveSettingsDebounced(); }