Skip to content
Clone
f0a1552
18 lines 868 B
import { chatSeedKey, prefetch, roomKey } from '@/shared/lib'
import { getRoom, listMessages, listRoomMembers, MESSAGE_PAGE_SIZE } from '@/entities/chat'
/**
* Hover prefetch for one room: the expensive core of what the chat column
* loads on mount — the room row, the member directory and the tail seed page.
* Pins / threads / emojis are cheap and panel-dependent, so they stay
* mount-time fetches. Fire-and-forget by design: a failed prefetch is silent,
* the mounting hooks surface real errors themselves.
*/
export function prefetchRoomView(roomId: string): void {
if (!roomId) return
void prefetch(roomKey(roomId, 'room'), () => getRoom(roomId))
void prefetch(roomKey(roomId, 'members'), () => listRoomMembers(roomId).catch(() => []))
void prefetch(chatSeedKey(roomId, null), () =>
listMessages(roomId, { limit: MESSAGE_PAGE_SIZE }),
)
}