From e180d9651c61bc68a45ea146f9aee7903f13bbff Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Tue, 13 Oct 2026 17:07:29 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=86=A0=EC=8A=A4=ED=8C=90=EC=9D=80=20?= =?UTF-8?q?=EC=A7=80=EC=97=AD=EC=9D=84=20=EA=B3=A0=EB=A5=B8=20=EC=A0=81=20?= =?UTF-8?q?=EC=9E=88=EC=96=B4=EB=8F=84=20=EC=9C=84=EC=B9=98=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=EC=9D=B4=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EC=98=AC=20=EB=95=8C=EB=A7=88=EB=8B=A4=20=EC=A7=80?= =?UTF-8?q?=EA=B8=88=20=EC=9C=84=EC=B9=98=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/region.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/b/region.tsx b/frontend/src/b/region.tsx index b829793..8e4a9fd 100644 --- a/frontend/src/b/region.tsx +++ b/frontend/src/b/region.tsx @@ -30,7 +30,7 @@ export function RegionProvider({ children }: { children: ReactNode }) { const [stored] = useState(readStored) const [region, setRegionState] = useState(stored ?? DEFAULT_REGION) const canLocate = IS_TOSS || (typeof navigator !== 'undefined' && 'geolocation' in navigator) - const [locateStatus, setLocateStatus] = useState(!stored && canLocate ? 'locating' : 'idle') + const [locateStatus, setLocateStatus] = useState((!stored || IS_TOSS) && canLocate ? 'locating' : 'idle') const setRegion = useCallback((r: RegionData) => { setRegionState(r) @@ -49,9 +49,10 @@ export function RegionProvider({ children }: { children: ReactNode }) { .catch(() => setLocateStatus('error')) }, [setRegion]) - const findNearest = useCallback((onFound?: () => void) => { + // ask=false 면 토스에서 권한 창 없이, 이미 허용한 사람만 위치로 맞춘다 + const findNearest = useCallback((onFound?: () => void, ask = true) => { if (IS_TOSS) { - tossLocation(true).then( + tossLocation(ask).then( (loc) => { if (loc === null) setLocateStatus('idle') else if (loc === 'denied') setLocateStatus('denied') @@ -80,9 +81,11 @@ export function RegionProvider({ children }: { children: ReactNode }) { findNearest(onFound) }, [canLocate, findNearest]) - // 처음 온 사람만 위치 권한을 물어 가장 가까운 구로 맞춘다 + // 처음 온 사람은 위치 권한을 물어 가장 가까운 구로 맞춘다. 토스판은 지역을 고른 적 있어도 권한이 있으면 들어올 때마다 지금 위치로 useEffect(() => { - if (!stored && canLocate) findNearest() + if (!canLocate) return + if (!stored) findNearest() + else if (IS_TOSS) findNearest(undefined, false) }, [stored, canLocate, findNearest]) const api = useMemo(() => ({ region, setRegion, locate, locateStatus }), [region, setRegion, locate, locateStatus])