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

@@ -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])),