feat: 앱 이름 '날씨각'·해 아이콘·스플래시, 위치 찾기 10초 제한, 첫 로딩 덮개가 안 걷히던 것 수정
This commit is contained in:
1 parent
b5d9adf396
commit
4fc9214de5
27 files changed
+30
-61
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { TimeKind } from '@nalssigak/shared/lib';
|
||||
import { useIsFetching } from '@tanstack/react-query';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
|
||||
@@ -38,19 +38,23 @@ function Hop({ name }: { name: string }) {
|
||||
|
||||
/** 처음 들어올 때만: 첫 데이터를 다 받을 때까지 하늘 위에 캐릭터와 '날씨 불러오는 중…'. 한 번 사라지면 다시 안 뜬다 */
|
||||
export function FirstLoad() {
|
||||
const fetching = useIsFetching();
|
||||
const queryClient = useQueryClient();
|
||||
const { kind } = useSky();
|
||||
const [started, setStarted] = useState(false);
|
||||
const [done, setDone] = useState(false);
|
||||
const [gone, setGone] = useState(false);
|
||||
// 받기 시작했다가 받는 게 없어지면 끝 (렌더 중에 바로 맞춘다)
|
||||
if (fetching > 0 && !started) setStarted(true);
|
||||
if (fetching === 0 && started && !done) setDone(true);
|
||||
// 느린 망에서도 10초 넘게 막지 않는다 (그 뒤는 화면 안 스켈레톤이 맡는다)
|
||||
// 받기 시작했다가 받는 게 없어지면 끝. 느린 망에서도 10초 넘게 막지 않는다 (그 뒤는 화면 안 스켈레톤이 맡는다)
|
||||
useEffect(() => {
|
||||
let seen = false;
|
||||
const unsubscribe = queryClient.getQueryCache().subscribe(() => {
|
||||
if (queryClient.isFetching() > 0) seen = true;
|
||||
else if (seen) setDone(true);
|
||||
});
|
||||
const id = setTimeout(() => setDone(true), 10000);
|
||||
return () => clearTimeout(id);
|
||||
}, []);
|
||||
return () => {
|
||||
unsubscribe();
|
||||
clearTimeout(id);
|
||||
};
|
||||
}, [queryClient]);
|
||||
const shown = useSharedValue(1);
|
||||
useEffect(() => {
|
||||
if (!done) return;
|
||||
|
||||
Reference in new issue
Block a user