4facc6b371
* implement avatar backend functionality * add avatar endpoints * typo * implement client side avatar upload and handling * fixes * Update go/internal/handler/handler.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update js/desktop/src/lib/avatar-image.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * bug in order * remove unused component * fix invalid migration * fix syntax errors --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
21 lines
689 B
TypeScript
21 lines
689 B
TypeScript
import { useQuery, skipToken } from '@tanstack/react-query';
|
|
import { apiClient } from '@/api/client';
|
|
|
|
/**
|
|
* Resolves an avatar object id to a signed download URL. Mirrors
|
|
* {@link import('./use-download-url').useDownloadUrl} — React Query handles
|
|
* caching and de-duping, so many avatars sharing an id make a single request.
|
|
*/
|
|
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;
|
|
}
|