From fd5748f8dfe792a45e0bc4a5a05c135bb7e01df8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Dec 2025 20:38:29 -0500 Subject: [PATCH] Fix startup crash after filter changes --- src/components/Map/usePostsEngine.js | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/Map/usePostsEngine.js b/src/components/Map/usePostsEngine.js index d5f82a4..f448a2e 100644 --- a/src/components/Map/usePostsEngine.js +++ b/src/components/Map/usePostsEngine.js @@ -430,26 +430,6 @@ export function usePostsEngine({ }, 120); }, [mapReady, mapRef]); - useEffect(() => { - const map = mapRef.current; - replacePoolRef.current = true; - pendingFilterRef.current = `${mainFilter}|${subFilter}|${timeHours}`; - allPostsRef.current = []; - setVisiblePosts([]); - syncMarkers([]); - if (map && clustersEnabled && heatmapEnabled) { - updateClusterAreas(map, []); - } - if (map) { - map.__swForceFetchAt = Date.now(); - setTimeout(() => { - try { - map.fire("moveend"); - } catch {} - }, 60); - } - }, [mainFilter, subFilter, timeHours, mapRef, syncMarkers, clustersEnabled, heatmapEnabled, updateClusterAreas]); - const priorityOpts = { maxFullCards: 15, clusterRadius: 0.002, @@ -838,6 +818,26 @@ export function usePostsEngine({ [mapRef, markersRef, expandedElRef, theme, searchQuery, forceFullPostId] ); + useEffect(() => { + const map = mapRef.current; + replacePoolRef.current = true; + pendingFilterRef.current = `${mainFilter}|${subFilter}|${timeHours}`; + allPostsRef.current = []; + setVisiblePosts([]); + syncMarkers([]); + if (map && clustersEnabled && heatmapEnabled) { + updateClusterAreas(map, []); + } + if (map) { + map.__swForceFetchAt = Date.now(); + setTimeout(() => { + try { + map.fire("moveend"); + } catch {} + }, 60); + } + }, [mainFilter, subFilter, timeHours, mapRef, syncMarkers, clustersEnabled, heatmapEnabled, updateClusterAreas]); + const computeVisible = useCallback( (tf) => { const basePosts = allPostsRef.current || [];