Let the News panel narrow the window to 12, 6, 3 or 1 hours

The panel's window label becomes a choice of the server's window and each
shorter one. The feed and map filter to it locally; the hotspot counts are
read again for it (/api/news/hotspots?hours=N, now on the allowlist). A
server names the longest window it serves as maxWindowHours.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:28 +01:00
1 parent ee3593cfbd
commit 4817d2a648
22 files changed
+198 -21

No files matched your search

+10 -9
View File
@@ -95,10 +95,15 @@ function normalizeDeveloping(items) {
return out;
}
const hoursOrNull = (hours) =>
Number.isInteger(hours) && hours >= 1 && hours <= 24 ? hours : null;
/**
* `/api/news/hotspots` → `{hotspots, categories, lastRunAt, windowHours}`
* (`windowHours` null when the server names none), or null when the
* payload has no hotspot list.
* `/api/news/hotspots` → `{hotspots, categories, lastRunAt, windowHours,
* maxWindowHours}`, or null when the payload has no hotspot list.
* `windowHours` is the window the counts cover and `maxWindowHours` the
* longest the server serves this reader; each is null when the server names
* none.
*/
export function normalizeHotspotsPayload(payload) {
if (!Array.isArray(payload?.hotspots)) return null;
@@ -136,12 +141,8 @@ export function normalizeHotspotsPayload(payload) {
)
: [],
lastRunAt: iso(payload.ingest?.lastRunAt),
windowHours:
Number.isInteger(payload.windowHours) &&
payload.windowHours >= 1 &&
payload.windowHours <= 24
? payload.windowHours
: null,
windowHours: hoursOrNull(payload.windowHours),
maxWindowHours: hoursOrNull(payload.maxWindowHours),
};
}