Keep the news layer inside its day and its memory bounds

From review of the news layer:
- An event's other sides older than 24 hours (or undated) are no longer
  listed, and a report dated more than 15 minutes ahead is outside the
  window, as in the regional brief.
- Picture cards are one canvas per event in a bounded cache (24), repainted
  in place when the age changes, with each card's picture dropped with it;
  the age in the key had made a new canvas every minute.
- The feed list drops reports that leave the window and is capped at 600.
- "In view" is filtered from the reports the layer already holds; it reads
  the feed only with minor news on, once per refresh, never per pan.
- Infinite scroll restarts after a filter change or a failed read.
- The two filter selects stack, so "Significant and above" is not cut off.
- The timeout tests hold the event loop until aborted, so they pass on
  Node 22 as well.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:25 +01:00
1 parent 138cc77a11
commit e95ae7b80c
11 files changed
+560 -90

No files matched your search

+9 -1
View File
@@ -13,7 +13,8 @@ const set = (node, key, value) => {
* The News rail panel (`#news-panel`): it renders the `feed` view the news
* layer publishes through its row controls, shows itself only while the
* layer is on, and acts only through setLayerParams. Near the bottom of its
* scroller it asks for the next older page, once per page.
* scroller it asks for the next older page, once per page; other filters or a
* failed read let it ask again.
*/
export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
const document = container?.ownerDocument;
@@ -25,6 +26,7 @@ export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
let view = null;
let destroyed = false;
let requestedAt = -1;
let shownFilters = '';
function render() {
if (destroyed) return;
@@ -59,6 +61,12 @@ export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
return {
/** Show the layer's feed view, or hide the panel with null. */
update(next) {
const filters = JSON.stringify(next?.filters ?? null);
// A new list (other filters or hotspot), or a read that failed, may stop
// at the same length as the last request: let the next scroll ask.
if (filters !== shownFilters || (next?.error && !view?.error))
requestedAt = -1;
shownFilters = filters;
view = next || null;
render();
},