From 85fd1d081d72a9030d80c5c9a69ef42dbf1d88a1 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 11 May 2026 23:21:16 +0000 Subject: [PATCH] Fetch updates to communication when SSE pushes a message --- ts/store/communication.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ts/store/communication.ts b/ts/store/communication.ts index a0d35b4a..fb63ee0d 100644 --- a/ts/store/communication.ts +++ b/ts/store/communication.ts @@ -14,8 +14,11 @@ export const useCommunicationStore = defineStore("communication", () => { // Subscription SSEManager.subscribe((msg: SSEMessageResource) => { - if (msg.resource.startsWith("rmo:")) { - fetchAll(); + if ( + msg.resource.startsWith("sync:communication") && + msg.type == "updated" + ) { + fetchOne(msg.uri); } }); // Actions @@ -44,6 +47,18 @@ export const useCommunicationStore = defineStore("communication", () => { loading.value = false; } } + async function fetchOne(uri: string) { + const data = (await apiClient.JSONGet(uri)) as CommunicationDTO; + if (!all.value) { + return; + } + for (var i = 0; i < all.value.length; i++) { + const c = all.value[i]; + if (c.uri == data.uri) { + all.value[i] = Communication.fromJSON(data); + } + } + } return { // State all,