From ac626a9c2edc2e528eb0b39002c836a747b2fc16 Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <ariel@costas.dev>
Date: Mon, 16 Mar 2026 14:13:26 +0100
Subject: feat: enhance geolocation handling with loading state and improve
 button click behavior

---
 src/frontend/app/contexts/MapContext.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/frontend/app/contexts/MapContext.tsx')

diff --git a/src/frontend/app/contexts/MapContext.tsx b/src/frontend/app/contexts/MapContext.tsx
index d93fefc..2c199be 100644
--- a/src/frontend/app/contexts/MapContext.tsx
+++ b/src/frontend/app/contexts/MapContext.tsx
@@ -72,6 +72,7 @@ export const MapProvider = ({ children }: { children: ReactNode }) => {
   const setLocationPermission = useCallback(
     (hasLocationPermission: boolean) => {
       setMapState((prev) => {
+        if (prev.hasLocationPermission === hasLocationPermission) return prev;
         const newState = { ...prev, hasLocationPermission };
         localStorage.setItem("mapState", JSON.stringify(newState));
         return newState;
@@ -103,7 +104,6 @@ export const MapProvider = ({ children }: { children: ReactNode }) => {
       (position) => {
         const { latitude, longitude } = position.coords;
         setUserLocation([latitude, longitude]);
-        setLocationPermission(true);
       },
       (error) => {
         if (error.code === GeolocationPositionError.PERMISSION_DENIED) {
-- 
cgit v1.3

