From 237273150429e4ae2cf35cc3855b54f9aad6a5d6 Mon Sep 17 00:00:00 2001 From: byGalax Date: Tue, 2 Jun 2026 20:26:00 +0200 Subject: [PATCH] feat(desktop): expose reactions reveal-gate flag (ready) --- apps/desktop/src/lib/useMessageReactions.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/lib/useMessageReactions.ts b/apps/desktop/src/lib/useMessageReactions.ts index e8800e7..b24d965 100644 --- a/apps/desktop/src/lib/useMessageReactions.ts +++ b/apps/desktop/src/lib/useMessageReactions.ts @@ -19,6 +19,10 @@ export interface UseMessageReactionsResult { byMessage: Map; toggle: (messageId: string, emoji: string) => Promise; voteExclusive: (messageId: string, emoji: string, exclusiveEmojis: string[]) => Promise; + // True once the reactions for the current message-id set have been fetched + // (or there are no messages). Drives MessageList's deferred reveal so the + // chat opens already showing reaction chips — no post-paint height jump. + ready: boolean; } // Batch-fetches reactions for the given message ids + subscribes to the @@ -29,10 +33,12 @@ export function useMessageReactions( ): UseMessageReactionsResult { const idsKey = useMemo(() => messageIds.join(','), [messageIds]); const [rows, setRows] = useState([]); + const [readyKey, setReadyKey] = useState(null); const refresh = useCallback(async () => { if (messageIds.length === 0) { setRows([]); + setReadyKey(idsKey); return; } try { @@ -40,6 +46,8 @@ export function useMessageReactions( setRows(data); } catch (err: unknown) { console.error('listReactionsForMessages failed', err); + } finally { + setReadyKey(idsKey); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [idsKey]); @@ -129,5 +137,7 @@ export function useMessageReactions( [byMessage, myId, refresh], ); - return { byMessage, toggle, voteExclusive }; + const ready = readyKey === idsKey; + + return { byMessage, toggle, voteExclusive, ready }; }