Play does nothing at live (#1915)

* Play does nothing at live

At live the clock is already at now, running with the world, so Play on the
timeline leaves it there instead of jumping to the start of the track and
playing it from there. Paused in the past, Play runs from that time; paused at
the end of the track, it starts again from the top, as before.

* Format worldTime.js; changelog fragment for #1915
This commit is contained in:
Sameh Khamis authored and GitHub committed 2026-11-23 10:57:55 -08:00
1 parent 1f105a68af
commit 43bd25382d
3 files changed
+28 -8

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
- Leave the clock at live when Play is pressed at live. Play used to jump to
the start of the track and play the whole range from there; paused in the
past it still plays from that time (samehkhamis, #1915).
+7 -6
View File
@@ -141,17 +141,18 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
time,
/**
* Play runs the track at the world clock's rate (the speed chosen, which
* sets it), from the start when it is at
* its end (at live, say), as a video plays again from the top. It runs
* the clock itself: weather follows the time frame by frame like every
* other layer the track covers.
* sets it), from where the clock is, or from the start when it is paused
* at the track's end, as a video plays again from the top. At live it
* does nothing: the clock is already at now, running with the world. It
* runs the clock itself: weather follows the time frame by frame like
* every other layer the track covers.
*/
togglePlay() {
const { playing, live, timeMs, span } = time.value;
if (playing) return worldClock.pause();
if (live) return;
const covered = reach();
if (span && covered && (live || timeMs >= covered.end))
worldClock.seek(span.start);
if (span && covered && timeMs >= covered.end) worldClock.seek(span.start);
// At the clock's rate: the speed chosen, or a host's own.
worldClock.play({ continuous: true });
},
+18 -2
View File
@@ -186,7 +186,7 @@ test('on a track that runs over years, only the last minutes are near now', asyn
assert.equal(worldClock.isLive(), true, 'a minute back goes live');
});
test('play runs in real time, from the start of the track when at live', async (t) => {
test('play does nothing at live, and runs in real time from a time in the past', async (t) => {
const bar = mount(t);
const now = Date.now();
const start = now - 10 * 86_400_000;
@@ -207,12 +207,23 @@ test('play runs in real time, from the start of the track when at live', async (
pause: () => stepped.push('pause'),
});
t.after(() => driver.detach());
assert.equal(worldClock.isLive(), true);
bar().querySelector('.world-timeline-play').click();
await nextTick();
assert.equal(worldClock.isLive(), true, 'play at live stays live');
assert.equal(worldClock.isPlaying(), false, 'and plays nothing');
assert.ok(Math.abs(worldClock.now() - Date.now()) < 60_000, 'still at now');
// Paused in the past, play runs from there.
const from = start + 86_400_000;
worldClock.seek(from);
await nextTick();
bar().querySelector('.world-timeline-play').click();
worldClock.pause();
await nextTick();
assert.deepEqual(stepped, []);
const rate = worldClock.getRate();
assert.ok(worldClock.now() - start < rate * 1_000, 'from the start of the track');
assert.ok(Math.abs(worldClock.now() - from) < rate * 1_000, 'from where it was');
assert.equal(rate, 1, 'real time to start with');
worldClock.play({ continuous: true });
@@ -275,6 +286,8 @@ test('the speed chosen sets how fast play runs, at once while playing', async (t
);
select.value = 'week';
select.dispatchEvent(new Event('change'));
// Play runs from a time in the past (at live it does nothing).
worldClock.seek(now - 5 * 86_400_000);
await nextTick();
bar().querySelector('.world-timeline-play').click();
assert.equal(worldClock.getRate(), 604_800, 'a week a second');
@@ -763,6 +776,9 @@ test('the speed shown follows the world clock, and Play runs at its rate', async
worldClock.setRate(5_000);
await nextTick();
assert.equal(select().value, 'hour');
// Play runs from a time in the past (at live it does nothing).
worldClock.seek(now - 5 * 86_400_000);
await nextTick();
bar().querySelector('.world-timeline-play').click();
assert.equal(worldClock.isPlaying(), true);
assert.equal(worldClock.getRate(), 5_000, 'Play runs at the clock\'s own rate');