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 <pvan@bach.cz>
This commit is contained in:
Enerccio
2026-04-16 20:10:19 +02:00
committed by GitHub
parent 0ac31c8fcd
commit 277285d30c
2 changed files with 8 additions and 0 deletions
+3
View File
@@ -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]);
+5
View File
@@ -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');
}