From 8942cf3c705bbc78a6b3317599658e9bb86dd31b Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <ariel@costas.dev>
Date: Mon, 16 Mar 2026 13:56:06 +0100
Subject: Add legal document shenanigans

Closes #147
---
 src/frontend/app/contexts/MapContext.tsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(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 75851f4..d93fefc 100644
--- a/src/frontend/app/contexts/MapContext.tsx
+++ b/src/frontend/app/contexts/MapContext.tsx
@@ -25,15 +25,23 @@ interface MapContextProps {
 
 const MapContext = createContext<MapContextProps | undefined>(undefined);
 
+const LOCATION_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
+
 export const MapProvider = ({ children }: { children: ReactNode }) => {
   const [mapState, setMapState] = useState<MapState>(() => {
     const savedMapState = localStorage.getItem("mapState");
     if (savedMapState) {
       try {
         const parsed = JSON.parse(savedMapState);
+        const locationAge = parsed.userLocationTimestamp
+          ? Date.now() - parsed.userLocationTimestamp
+          : Infinity;
         return {
           paths: parsed.paths || {},
-          userLocation: parsed.userLocation || null,
+          userLocation:
+            locationAge < LOCATION_TTL_MS
+              ? (parsed.userLocation ?? null)
+              : null,
           hasLocationPermission: parsed.hasLocationPermission || false,
         };
       } catch (e) {
@@ -51,7 +59,11 @@ export const MapProvider = ({ children }: { children: ReactNode }) => {
 
   const setUserLocation = useCallback((userLocation: LngLatLike | null) => {
     setMapState((prev) => {
-      const newState = { ...prev, userLocation };
+      const newState = {
+        ...prev,
+        userLocation,
+        userLocationTimestamp: userLocation ? Date.now() : null,
+      };
       localStorage.setItem("mapState", JSON.stringify(newState));
       return newState;
     });
-- 
cgit v1.3

