17 lines
534 B
TypeScript
17 lines
534 B
TypeScript
import { useMemo } from 'react';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { apiFetch } from '../lib/api';
|
|
|
|
export function useFollowing(): Set<string> {
|
|
const { data, error } = useQuery({
|
|
queryKey: ['me-following'],
|
|
queryFn: async () => {
|
|
const r = await apiFetch<{ userIds: string[] }>('/api/me/following');
|
|
return r;
|
|
},
|
|
staleTime: 5 * 60_000,
|
|
});
|
|
if (error) console.warn('[presence] /api/me/following ERROR:', error);
|
|
return useMemo(() => new Set(data?.userIds ?? []), [data]);
|
|
}
|