From bc9700d5225ede1655b7f6a463a618a6d5b59e74 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 29 Dec 2025 22:39:05 -0500 Subject: [PATCH] Use published_at for pruning and search radius --- src/components/Map/usePostsEngine.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/Map/usePostsEngine.js b/src/components/Map/usePostsEngine.js index 474f02a..3583d92 100644 --- a/src/components/Map/usePostsEngine.js +++ b/src/components/Map/usePostsEngine.js @@ -134,7 +134,13 @@ function filterByBounds(posts, map) { function getPostTimeMs(p) { - const raw = p?.created_at || p?.CreatedAt || p?.createdAt || p?.published_at; + const raw = + p?.published_at || + p?.publishedAt || + p?.PublishedAt || + p?.created_at || + p?.CreatedAt || + p?.createdAt; if (!raw) return 0; const d = raw instanceof Date ? raw : new Date(String(raw)); if (Number.isNaN(d.getTime())) return 0; @@ -1094,15 +1100,26 @@ export function usePostsEngine({ const map = mapRef.current; let lat; let lon; + let radiusKm; try { - const center = map?.getCenter?.(); - lat = center?.lat; - lon = center?.lng; + const view = map ? getViewFromMap(map) : null; + if (view?.center) { + lon = view.center[0]; + lat = view.center[1]; + } else { + const center = map?.getCenter?.(); + lat = center?.lat; + lon = center?.lng; + } + if (view?.radiusKm) { + radiusKm = Math.min(Math.max(view.radiusKm * 1.2, 25), 2500); + } } catch {} const data = await fetchUnifiedSearch(q, { type: "posts", lat, lon, + radius_km: radiusKm, limit: 60, }); if (cancelled) return;