Show news from the window the server serves

A host may serve fewer hours than the day. The hotspots answer may name its window
(`windowHours`, a whole number from 1 to 24); the layer keeps reports, the
feed, In view and the chosen event inside it, and the panel says
"Last 12 h" or "Last 24 h" accordingly. Without a window named, or with one
out of range, the layer keeps the full day as before.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:27 +01:00
1 parent f3e206bf37
commit 60fad38c3f
18 files changed
+178 -73

No files matched your search

+16 -5
View File
@@ -7,7 +7,8 @@ import UiSelect from '../kit/UiSelect.js';
import RailChips from '../rail/RailChips.vue';
import NewsCard from './NewsCard.vue';
// The News panel: the last 24 hours only. Hotspot chips, filters, the chosen
// The News panel: the window the server serves only (the last 24 hours, or
// fewer where the host serves less). Hotspot chips, filters, the chosen
// event, "In view" (reports near the view centre while the camera is low)
// and a continuous feed, newest first. It renders the `feed` view the news
// layer publishes and acts only through `onParams`.
@@ -75,9 +76,11 @@ const clear = () => props.onParams({ clear: true });
<section
v-if="view"
class="news-readout"
:aria-label="t('News, last 24 hours')"
:aria-label="t('News, last {hours} hours', { hours: view.windowHours })"
>
<p class="news-readout__window ui-mono">{{ t('Last 24 h') }}</p>
<p class="news-readout__window ui-mono">{{
t('Last {hours} h', { hours: view.windowHours })
}}</p>
<div class="news-readout__chips" role="group" :aria-label="t('Hotspots')">
<RailChips
:chips="chips"
@@ -136,7 +139,11 @@ const clear = () => props.onParams({ clear: true });
<UiEmpty
v-else-if="!view.inView.items.length && !view.inView.loading"
class="news-readout__empty"
:title="t('Nothing reported near here in the last 24 h')"
:title="
t('Nothing reported near here in the last {hours} h', {
hours: view.windowHours,
})
"
/>
<ol
v-else
@@ -173,7 +180,11 @@ const clear = () => props.onParams({ clear: true });
<UiEmpty
v-else-if="!view.loading && !view.error"
class="news-readout__empty"
:title="t('No news matches these filters in the last 24 h')"
:title="
t('No news matches these filters in the last {hours} h', {
hours: view.windowHours,
})
"
/>
<div class="news-readout__footer">
<span class="news-readout__status" role="status">{{ status }}</span>
+10
View File
@@ -76,6 +76,7 @@ function view(extra = {}) {
inView: { active: false, loading: false, error: null, items: [] },
selected: null,
hasMore: true,
windowHours: 24,
loading: false,
error: null,
...extra,
@@ -276,3 +277,12 @@ test('scrolling to the end asks once per page, again after a filter change or a
assert.equal(loadMores(), 3);
news.destroy();
});
test('the panel names the window the server serves', () => {
const { news, panel } = fixture();
news.update(view({ windowHours: 12 }));
assert.equal(
panel.querySelector('.news-readout__window').textContent,
'Last 12 h',
);
});