Use published_at for pruning and search radius
This commit is contained in:
parent
0bd4988ad7
commit
bc9700d522
|
|
@ -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 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue