mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-25 20:15:37 +02:00
fix(realtime): update issue in-place on WS event to prevent inbox loading flash
When viewing an issue in the inbox, issue:updated WS events triggered a full useIssueStore.fetch() that replaced the entire issues array. This caused all consumers to re-render, producing a loading flash. Now issue:updated events use the WS payload to surgically update the single affected issue via updateIssue(), avoiding array replacement. Other issue events (created/deleted) still use full refetch. WS reconnect recovery path is unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,20 @@ export function useRealtimeSync(ws: WSClient | null) {
|
||||
logger.debug("skipping self-event", msg.type);
|
||||
return;
|
||||
}
|
||||
|
||||
// issue:updated — update in-place using WS payload instead of full
|
||||
// refetch. Replacing the entire issues array causes every consumer
|
||||
// (including IssueDetail in the inbox) to re-render, which can flash
|
||||
// a loading state. The payload already contains the full issue object
|
||||
// so a surgical merge is safe.
|
||||
if (msg.type === "issue:updated") {
|
||||
const { issue } = (msg.payload ?? {}) as IssueUpdatedPayload;
|
||||
if (issue?.id) {
|
||||
useIssueStore.getState().updateIssue(issue.id, issue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const prefix = msg.type.split(":")[0] ?? "";
|
||||
const refresh = refreshMap[prefix];
|
||||
if (refresh) debouncedRefresh(prefix, refresh);
|
||||
|
||||
Reference in New Issue
Block a user