From e691b6c9a2182ede263dd355d0d31f0f65c62380 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:15:36 +0000 Subject: fix: address code review - clarify [lat,lng] convention, add effect deps, use ref for initial permission" Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com> --- src/frontend/app/contexts/MapContext.tsx | 9 +++++---- src/frontend/app/hooks/useGeolocation.ts | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/frontend/app') diff --git a/src/frontend/app/contexts/MapContext.tsx b/src/frontend/app/contexts/MapContext.tsx index 195c6e6..75851f4 100644 --- a/src/frontend/app/contexts/MapContext.tsx +++ b/src/frontend/app/contexts/MapContext.tsx @@ -117,6 +117,8 @@ export const MapProvider = ({ children }: { children: ReactNode }) => { ); }, [setUserLocation, setLocationPermission, startWatching]); + const hasPermissionRef = useRef(mapState.hasLocationPermission); + // On mount: subscribe to permission changes and auto-start watching if already granted useEffect(() => { if (typeof window === "undefined" || !("geolocation" in navigator)) return; @@ -149,11 +151,11 @@ export const MapProvider = ({ children }: { children: ReactNode }) => { setLocationPermission(false); } permissionStatus.addEventListener("change", onPermChange); - } else if (mapState.hasLocationPermission) { + } else if (hasPermissionRef.current) { startWatching(); } } catch { - if (mapState.hasLocationPermission) { + if (hasPermissionRef.current) { startWatching(); } } @@ -168,8 +170,7 @@ export const MapProvider = ({ children }: { children: ReactNode }) => { } permissionStatus?.removeEventListener("change", onPermChange); }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [startWatching, setLocationPermission]); return (