From 277285d30cb096cfc93c92b27f3e0afa1003cba6 Mon Sep 17 00:00:00 2001 From: Enerccio Date: Thu, 16 Apr 2026 20:10:19 +0200 Subject: [PATCH] implemented emit events for itemized-prompts.js (#5461) * implemented emit events for itemized-prompts.js * removed redundant ITEMIZED_PROMPTS_DELETED_ALL event and updated emit logic accordingly --------- Co-authored-by: Peter Vanusanik --- public/scripts/events.js | 3 +++ public/scripts/itemized-prompts.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/public/scripts/events.js b/public/scripts/events.js index e48ccbd39..852eaa7fc 100644 --- a/public/scripts/events.js +++ b/public/scripts/events.js @@ -105,6 +105,9 @@ export const event_types = { TTS_JOB_STARTED: 'tts_job_started', TTS_AUDIO_READY: 'tts_audio_ready', TTS_JOB_COMPLETE: 'tts_job_complete', + ITEMIZED_PROMPTS_LOADED: 'itemized_prompts_loaded', + ITEMIZED_PROMPTS_SAVED: 'itemized_prompts_saved', + ITEMIZED_PROMPTS_DELETED: 'itemized_prompts_deleted', }; export const eventSource = new EventEmitter([event_types.APP_READY, event_types.APP_INITIALIZED]); diff --git a/public/scripts/itemized-prompts.js b/public/scripts/itemized-prompts.js index 1ef98dc7a..8bc9b78e5 100644 --- a/public/scripts/itemized-prompts.js +++ b/public/scripts/itemized-prompts.js @@ -31,6 +31,8 @@ export async function loadItemizedPrompts(chatId) { if (!itemizedPrompts) { itemizedPrompts = []; } + + await eventSource.emit(event_types.ITEMIZED_PROMPTS_LOADED, { chatId: chatId }); } catch { console.log('Error loading itemized prompts for chat', chatId); itemizedPrompts = []; @@ -48,6 +50,7 @@ export async function saveItemizedPrompts(chatId) { } await promptStorage.setItem(chatId, itemizedPrompts); + await eventSource.emit(event_types.ITEMIZED_PROMPTS_SAVED, { chatId: chatId }); } catch { console.log('Error saving itemized prompts for chat', chatId); } @@ -84,6 +87,7 @@ export async function deleteItemizedPrompts(chatId) { } await promptStorage.removeItem(chatId); + await eventSource.emit(event_types.ITEMIZED_PROMPTS_DELETED, { chatId: chatId, all: false }); } catch { console.log('Error deleting itemized prompts for chat', chatId); } @@ -96,6 +100,7 @@ export async function clearItemizedPrompts() { try { await promptStorage.clear(); itemizedPrompts = []; + await eventSource.emit(event_types.ITEMIZED_PROMPTS_DELETED, { all: true }); } catch { console.log('Error clearing itemized prompts'); }