Fix out of order path WS broadcasts overwriting each other

This commit is contained in:
Jack Kingsman
2026-02-16 18:30:27 -08:00
parent 8457799a60
commit 1f853aa54e
2 changed files with 9 additions and 3 deletions

View File

@@ -91,6 +91,10 @@ Specialized logic is delegated to hooks:
- WebSocket: realtime deltas/events.
- On WS connect, backend sends `health` only; contacts/channels still come from REST.
### New Message modal
`NewMessageModal` intentionally preserves form state (tab, inputs, checkboxes) when closed and reopened. The component instance persists across open/close cycles. This is by design so users don't lose in-progress input if they accidentally dismiss the dialog.
### Message behavior
- Outgoing sends are optimistic in UI and persisted server-side.

View File

@@ -70,11 +70,13 @@ export function updateAck(messageId: number, ackCount: number, paths?: MessagePa
for (const entry of cache.values()) {
const idx = entry.messages.findIndex((m) => m.id === messageId);
if (idx >= 0) {
const current = entry.messages[idx];
const updated = [...entry.messages];
updated[idx] = {
...entry.messages[idx],
acked: ackCount,
...(paths !== undefined && { paths }),
...current,
acked: Math.max(current.acked, ackCount),
...(paths !== undefined &&
paths.length >= (current.paths?.length ?? 0) && { paths }),
};
entry.messages = updated;
return; // Message IDs are unique, stop after first match