MCPcopy Create free account
hub / github.com/msgbyte/tailchat / useCachedOnlineStatus

Function useCachedOnlineStatus

client/shared/cache/useCache.ts:9–30  ·  view source on GitHub ↗
(
  ids: string[],
  onOnlineStatusUpdate?: (onlineStatus: boolean[]) => void
)

Source from the content-addressed store, hash-verified

7 * 用户登录状态
8 */
9export function useCachedOnlineStatus(
10 ids: string[],
11 onOnlineStatusUpdate?: (onlineStatus: boolean[]) => void
12): boolean[] {
13 const staleTime = 20 * 1000; // 缓存20s
14
15 const { data, isSuccess } = useQuery(
16 ['onlineStatus', ids.join(',')],
17 () => getUserOnlineStatus(ids),
18 {
19 staleTime,
20 }
21 );
22
23 if (isSuccess && Array.isArray(data)) {
24 if (typeof onOnlineStatusUpdate === 'function' && data) {
25 onOnlineStatusUpdate(data);
26 }
27 }
28
29 return data ?? ids.map(() => false);
30}

Callers 3

UserListItem.tsxFile · 0.85
MembersPanel.tsxFile · 0.85

Calls 2

getUserOnlineStatusFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected