mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix: close race window that dropped active channel messages (#410)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -133,17 +133,18 @@ export function useLiveChannelUpdates(
|
||||
// when the user is already viewing the DM.
|
||||
handleDmEvent(event);
|
||||
|
||||
if (channelId === activeChannelId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!liveChannelIds.has(channelId)) {
|
||||
void queryClient.invalidateQueries({ queryKey: channelsQueryKey });
|
||||
if (channelId !== activeChannelId) {
|
||||
void queryClient.invalidateQueries({ queryKey: channelsQueryKey });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Always update the cache — even for the active channel.
|
||||
// useChannelSubscription also writes to this cache, but there's a
|
||||
// race window where it hasn't connected yet. Writes are idempotent
|
||||
// (mergeTimelineCacheMessages deduplicates by event ID).
|
||||
const messageTimestamp = getMessageTimestamp(event);
|
||||
|
||||
updateChannelLastMessageAt(queryClient, channelId, messageTimestamp);
|
||||
queryClient.setQueryData<RelayEvent[]>(
|
||||
channelMessagesKey(channelId),
|
||||
|
||||
Reference in New Issue
Block a user