Fix startup crash after filter changes

This commit is contained in:
Your Name 2025-12-30 20:38:29 -05:00
parent f251412f86
commit fd5748f8df
1 changed files with 20 additions and 20 deletions

View File

@ -430,26 +430,6 @@ export function usePostsEngine({
}, 120); }, 120);
}, [mapReady, mapRef]); }, [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 = { const priorityOpts = {
maxFullCards: 15, maxFullCards: 15,
clusterRadius: 0.002, clusterRadius: 0.002,
@ -838,6 +818,26 @@ export function usePostsEngine({
[mapRef, markersRef, expandedElRef, theme, searchQuery, forceFullPostId] [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( const computeVisible = useCallback(
(tf) => { (tf) => {
const basePosts = allPostsRef.current || []; const basePosts = allPostsRef.current || [];