Show the timeline only while a layer with time to show is on

The bar now needs more than the world clock being away from live: a layer
that moves with the clock must be on with time to show. In Core that is
weather radar, satellite or lightning with frames; a host adds layers by
following them. Turning the last one off hides the bar; turning it back
on brings it back.

The world clock reports this as `supported` in its state. Weather products
register their frames as coverage one by one, suspended or not, so the way
back to live stays on screen with reduced motion. Weather refreshes and
satellite catalog changes tell the clock their coverage may have changed.
A coverage that throws counts as none, and the clock reads its state once
per notification round.
This commit is contained in:
Sameh Khamis committed 2026-11-01 22:36:45 -08:00
1 parent 434fc9602d
commit 690a6637e2
12 files changed
+205 -25

No files matched your search

+39 -3
View File
@@ -8,7 +8,7 @@ import { createPinia } from 'pinia';
import { worldClock } from '../../../time/worldClock.js';
import WorldTimeline from './WorldTimeline.vue';
test('the timeline shows away from live and plays, pauses and goes back', async (t) => {
function mount(t) {
document.body.replaceChildren();
const app = createApp(WorldTimeline).use(createPinia());
app.mount(document.body.appendChild(document.createElement('div')));
@@ -16,11 +16,33 @@ test('the timeline shows away from live and plays, pauses and goes back', async
app.unmount();
worldClock.goLive();
});
const bar = () => document.getElementById('world-timeline');
return () => document.getElementById('world-timeline');
}
// A layer that moves with the clock and has an hour of frames.
function supportingLayer(t, at) {
const release = worldClock.hold('test-radar');
const unregister = worldClock.register({
id: 'test-radar',
coverage: () => ({ start: at - 3_600_000, end: at }),
});
t.after(() => {
unregister();
release();
});
return () => {
unregister();
release();
};
}
test('the timeline shows away from live and plays, pauses and goes back', async (t) => {
const bar = mount(t);
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
supportingLayer(t, at);
await nextTick();
assert.equal(bar(), null, 'hidden while live');
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
worldClock.seek(at);
await nextTick();
assert.ok(bar());
@@ -43,3 +65,17 @@ test('the timeline shows away from live and plays, pauses and goes back', async
assert.equal(worldClock.isLive(), true);
assert.equal(bar(), null);
});
test('the timeline hides while no layer with time to show is on', async (t) => {
const bar = mount(t);
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
worldClock.seek(at);
await nextTick();
assert.equal(bar(), null, 'away from live, but nothing to play');
const remove = supportingLayer(t, at);
await nextTick();
assert.ok(bar());
remove();
await nextTick();
assert.equal(bar(), null, 'the layer went off');
});
+4 -2
View File
@@ -8,7 +8,9 @@ import UiIcon from '../../kit/UiIcon.vue';
// The world time while it is away from live: what is playing, or where it
// was paused, with play and pause on the left and the way back to live on
// the right. Live, the bar stays hidden.
// the right. It shows only while a layer that moves with the clock (weather
// radar, satellite or lightning, or one a host follows) is on with time to
// show; live, or with none on, the bar stays hidden.
const store = useWorldTimeStore();
const { time } = storeToRefs(store);
@@ -25,7 +27,7 @@ const readout = computed(() =>
</script>
<template>
<div v-if="!time.live" id="world-timeline" role="group" :aria-label="t('World time')"
<div v-if="!time.live && time.supported" id="world-timeline" role="group" :aria-label="t('World time')"
><UiButton class="world-timeline-play" :label="time.playing ? t('Pause') : t('Play')" @click="store.togglePlay()"
><UiIcon :name="time.playing ? 'pause' : 'play_arrow'" :size="20" /></UiButton
><time class="world-timeline-time" :datetime="new Date(time.timeMs).toISOString()" aria-live="off">{{ readout }}</time