fix and update

This commit is contained in:
lendry
2026-06-30 10:36:21 +03:00
parent a76997986a
commit 7f10b18336
6 changed files with 73 additions and 29 deletions

View File

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

View File

@@ -13,7 +13,7 @@ import {
} from '@/lib/api';
export function useSelectedFamily(enabled = true) {
const { user, token, isPinLocked, isLoading, isApiReady } = useAuth();
const { user, token, isPinLocked, isLoading, isContentReady } = useAuth();
const { selectedGroupId, setSelectedGroupId } = useFamilyOverlay();
const [groups, setGroups] = useState<FamilyGroup[]>([]);
const [group, setGroup] = useState<FamilyGroup | null>(null);
@@ -22,7 +22,7 @@ export function useSelectedFamily(enabled = true) {
const refresh = useCallback(async () => {
const accessToken = getAccessToken() ?? token?.trim() ?? null;
if (!enabled || !user || !accessToken || isPinLocked || isLoading || !isApiReady) {
if (!enabled || !user || !accessToken || isPinLocked || isLoading || !isContentReady) {
setGroups([]);
setGroup(null);
setPresenceMembers([]);
@@ -62,7 +62,7 @@ export function useSelectedFamily(enabled = true) {
} finally {
setLoading(false);
}
}, [enabled, isApiReady, isLoading, isPinLocked, selectedGroupId, setSelectedGroupId, token, user]);
}, [enabled, isContentReady, isLoading, isPinLocked, selectedGroupId, setSelectedGroupId, token, user]);
useEffect(() => {
setLoading(true);
@@ -71,10 +71,10 @@ export function useSelectedFamily(enabled = true) {
useEffect(() => {
const accessToken = getAccessToken() ?? token?.trim() ?? null;
if (!enabled || !accessToken || isPinLocked || isLoading || !isApiReady || !group) return;
if (!enabled || !accessToken || isPinLocked || isLoading || !isContentReady || !group) return;
const timer = window.setInterval(() => void refresh(), 25_000);
return () => window.clearInterval(timer);
}, [enabled, group, isApiReady, isLoading, isPinLocked, refresh, token]);
}, [enabled, group, isContentReady, isLoading, isPinLocked, refresh, token]);
const presenceByUserId = useMemo(
() => new Map(presenceMembers.map((member) => [member.userId, member])),