Send zoom to smart feed and rely on reco
This commit is contained in:
parent
e15c78e950
commit
92e9cfc566
|
|
@ -289,6 +289,7 @@ export async function fetchSmartFeed(params = {}) {
|
|||
if (typeof params.lon === "number") qs.set("lon", String(params.lon));
|
||||
if (typeof params.radius_km === "number") qs.set("radius_km", String(params.radius_km));
|
||||
if (typeof params.limit === "number") qs.set("limit", String(params.limit));
|
||||
if (typeof params.zoom === "number") qs.set("zoom", String(params.zoom));
|
||||
|
||||
// NEW: Screen bounds for on-screen prioritization
|
||||
if (params.bounds) {
|
||||
|
|
|
|||
|
|
@ -654,60 +654,16 @@ export function usePostsEngine({
|
|||
subFilter && subFilter.toUpperCase() !== "ALL" && subFilter !== "All" ? subFilter : "";
|
||||
|
||||
// Use smart feed for personalized, trending posts
|
||||
const zoom = typeof mapObj?.getZoom === "function" ? mapObj.getZoom() : undefined;
|
||||
let newPosts = await fetchSmartFeed({
|
||||
lat,
|
||||
lon: lng,
|
||||
radius_km: radiusKm,
|
||||
limit: 40,
|
||||
limit: 50,
|
||||
zoom,
|
||||
bounds,
|
||||
username: username || undefined,
|
||||
});
|
||||
const timeParam = timeFilter && timeFilter !== "PAST" ? timeFilter : undefined;
|
||||
const smartCount = Array.isArray(newPosts) ? newPosts.length : 0;
|
||||
const needFallback = smartCount < 12 || !hasPostsInRadius(newPosts, lat, lng, radiusKm);
|
||||
if (needFallback) {
|
||||
const fallbackPosts = await fetchPosts({
|
||||
category: catCode || undefined,
|
||||
subCategory: subCatParam || undefined,
|
||||
time: timeParam,
|
||||
lat,
|
||||
lon: lng,
|
||||
radiusKm,
|
||||
limit: 120,
|
||||
});
|
||||
if ((!Array.isArray(fallbackPosts) || fallbackPosts.length === 0) && timeFilter !== "PAST") {
|
||||
const widenedPosts = await fetchPosts({
|
||||
category: catCode || undefined,
|
||||
subCategory: subCatParam || undefined,
|
||||
time: "PAST",
|
||||
lat,
|
||||
lon: lng,
|
||||
radiusKm,
|
||||
limit: 120,
|
||||
});
|
||||
const merged = new Map();
|
||||
for (const p of (newPosts || [])) {
|
||||
const key = getPostKey(p);
|
||||
if (key) merged.set(key, p);
|
||||
}
|
||||
for (const p of (widenedPosts || [])) {
|
||||
const key = getPostKey(p);
|
||||
if (key && !merged.has(key)) merged.set(key, p);
|
||||
}
|
||||
newPosts = Array.from(merged.values());
|
||||
} else {
|
||||
const merged = new Map();
|
||||
for (const p of (newPosts || [])) {
|
||||
const key = getPostKey(p);
|
||||
if (key) merged.set(key, p);
|
||||
}
|
||||
for (const p of (fallbackPosts || [])) {
|
||||
const key = getPostKey(p);
|
||||
if (key && !merged.has(key)) merged.set(key, p);
|
||||
}
|
||||
newPosts = Array.from(merged.values());
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelled) return;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue