import { skipToken, useQuery } from '@tanstack/react-query'; import { apiClient } from '@/api/client'; /** * Resolve an avatar object id to a signed download URL. React Query handles * caching and de-duping, so many avatars sharing an id make a single request. * Mirrors desktop's use-avatar-url. */ export function useAvatarUrl( objectId: string | null | undefined, ): string | undefined { const { data } = useQuery({ queryKey: ['avatar-url', objectId], queryFn: objectId ? () => apiClient.getAvatarDownloadUrl(objectId) : skipToken, staleTime: 1000 * 60 * 60, // 1 hour — signed URLs valid for 24h }); return data; }