feat: 앱 이름 '날씨각'·해 아이콘·스플래시, 위치 찾기 10초 제한, 첫 로딩 덮개가 안 걷히던 것 수정

This commit is contained in:
minaChoi committed 2026-10-14 16:39:37 +09:00
1 parent b5d9adf396
commit 4fc9214de5
27 files changed
+30 -61

No files matched your search

+6 -1
View File
@@ -29,11 +29,16 @@ function readStored(): RegionData | null {
}
}
/** 위치를 못 잡으면(실내·에뮬레이터) 끝없이 기다리지 않게 웹처럼 10초에 끊는다 */
function withTimeout<T>(p: Promise<T>, ms: number): Promise<T> {
return Promise.race([p, new Promise<never>((_, reject) => setTimeout(() => reject(new Error('위치 찾기 시간 초과')), ms))]);
}
/** 위치 권한을 받아 가장 가까운 구. 권한이 없으면 'denied' */
async function findNearest(): Promise<RegionData | 'denied'> {
const { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') return 'denied';
const pos = (await Location.getLastKnownPositionAsync({ maxAge: 600000 })) ?? (await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Balanced }));
const pos = (await Location.getLastKnownPositionAsync({ maxAge: 600000 })) ?? (await withTimeout(Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Balanced }), 10000));
const { data } = await nearestRegion({ query: { lat: pos.coords.latitude, lon: pos.coords.longitude } });
if (!data.region) throw new Error('가까운 구를 찾지 못함');
return data.region;