chahinebrini 35a71a9068 feat(presence): Online-Presence-Provider + Hooks
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 18:09:42 +02:00

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]);
}