fix and update

This commit is contained in:
lendry
2026-06-30 09:39:35 +03:00
parent 250976ca08
commit 4e98f6bfab
8 changed files with 192 additions and 110 deletions

View File

@@ -12,12 +12,12 @@ interface AvatarAccessResponse {
}
export function useAvatarUrl(userId: string | undefined, hasAvatar: boolean | undefined, token: string | null) {
const { isPinLocked, isLoading } = useAuth();
const { isPinLocked, isLoading, isApiReady } = useAuth();
const [accessUrl, setAccessUrl] = useState<string | null>(null);
const [resolvingAccessUrl, setResolvingAccessUrl] = useState(false);
const refreshAccessUrl = useCallback(async () => {
if (!userId || !token || !hasAvatar || isPinLocked || isLoading) {
if (!userId || !token || !hasAvatar || isPinLocked || isLoading || !isApiReady) {
setAccessUrl(null);
setResolvingAccessUrl(false);
return;
@@ -31,7 +31,7 @@ export function useAvatarUrl(userId: string | undefined, hasAvatar: boolean | un
} finally {
setResolvingAccessUrl(false);
}
}, [hasAvatar, isLoading, isPinLocked, token, userId]);
}, [hasAvatar, isApiReady, isLoading, isPinLocked, token, userId]);
useEffect(() => {
void refreshAccessUrl();
@@ -59,7 +59,7 @@ export function useAvatarUrl(userId: string | undefined, hasAvatar: boolean | un
isLoading: isLoadingBlob,
hasError
} = useResilientBlobUrl(accessUrl, token, {
enabled: Boolean(hasAvatar && accessUrl && !isPinLocked && !isLoading),
enabled: Boolean(hasAvatar && accessUrl && !isPinLocked && !isLoading && isApiReady),
label: `аватар ${userId ?? ''}`.trim()
});