mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Smaller review items: comment placement, dead helpers, locale clock, LIVE republish, STATION keyboard and touch
- getLiveSubjectKeys no longer sits between trackById's comment and body. - issCommandSunPoses and issCommandStatusText go: nothing called them. - The STATION section's 'no signal since' time is formatted in the app's locale (formatDate), not the browser's. - LiveControls sends an unchanged view only once: the 2 s refresh resends nothing (tested). - The STATION mode radios take arrow keys and keep only the checked one in the tab order; the LIVE stream arrows are 44 px on a coarse pointer.
This commit is contained in:
1 parent
2c9a268694
commit
7d0f9f677f
7 files changed
+50
-48
No files matched your search
+12
-2
@@ -74,6 +74,8 @@ export class LiveControls {
|
||||
this.cockpitActive =
|
||||
documentRef?.body?.classList?.contains?.('cockpit-mode') === true;
|
||||
this.timer = null;
|
||||
/** The view last published, as text: the 2 s refresh resends nothing new. */
|
||||
this.publishedKey = undefined;
|
||||
/** The stop held back for one tick after a clear (see `_onCleared`). */
|
||||
this.clearGrace = null;
|
||||
this.listeners = new AbortController();
|
||||
@@ -244,10 +246,18 @@ export class LiveControls {
|
||||
if (changed) this.actions.scheduleLayout?.();
|
||||
}
|
||||
|
||||
/** Publish `view` unless it is the one published last. */
|
||||
_send(view) {
|
||||
const key = JSON.stringify(view);
|
||||
if (key === this.publishedKey) return;
|
||||
this.publishedKey = key;
|
||||
this.store.publish(view);
|
||||
}
|
||||
|
||||
_publish() {
|
||||
if (this.destroyed) return;
|
||||
if (!this.subject || !this.offered.length) {
|
||||
this.store.publish(null);
|
||||
this._send(null);
|
||||
return;
|
||||
}
|
||||
const index = Math.max(
|
||||
@@ -255,7 +265,7 @@ export class LiveControls {
|
||||
this.offered.findIndex((stream) => stream.id === this.currentId),
|
||||
);
|
||||
const current = this.offered[index];
|
||||
this.store.publish({
|
||||
this._send({
|
||||
label: this.subject.label,
|
||||
streams: this.offered.map((stream) => ({
|
||||
id: stream.id,
|
||||
|
||||
@@ -428,3 +428,15 @@ test('destroy stops the stream, detaches the actions and publishes nothing', ()
|
||||
f.select();
|
||||
assert.equal(f.published.length, before, 'events after destroy are ignored');
|
||||
});
|
||||
|
||||
test('the 2 s refresh publishes nothing when nothing changed', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
const count = f.published.length;
|
||||
for (const timer of f.running()) timer.callback();
|
||||
for (const timer of f.running()) timer.callback();
|
||||
assert.equal(f.published.length, count, 'the same view is not sent again');
|
||||
f.store.act('playLive');
|
||||
assert.ok(f.published.length > count, 'a change is');
|
||||
});
|
||||
@@ -113,6 +113,12 @@
|
||||
.live-step .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.live-step {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
.live-step:hover,
|
||||
.live-step:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { formatNumber, t } from '../../../i18n/index.js';
|
||||
import { formatDate, formatNumber, t } from '../../../i18n/index.js';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
@@ -27,7 +27,7 @@ const ago = (ms) => {
|
||||
};
|
||||
const clock = (ms) =>
|
||||
Number.isFinite(ms)
|
||||
? new Date(ms).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
||||
? formatDate(ms, { hour: '2-digit', minute: '2-digit' })
|
||||
: '';
|
||||
const telemetry = computed(() => view.value?.telemetry ?? null);
|
||||
const telemetryText = computed(() => {
|
||||
@@ -65,6 +65,15 @@ const sunText = computed(() => {
|
||||
if (sunlit === null || sunlit === undefined) return '';
|
||||
return sunlit ? t('Now: in sunlight') : t("Now: in the Earth's shadow");
|
||||
});
|
||||
// The mode radios: arrow keys move the choice and the focus, as a radio
|
||||
// group's do, and only the checked one is in the tab order.
|
||||
function stepMode(event) {
|
||||
const next = manual.value ? 'automatic' : 'manual';
|
||||
act('setStationMode', next);
|
||||
event.currentTarget
|
||||
?.querySelector(`#station-${next}-btn`)
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
const stationWords = computed(() => ({
|
||||
expandLabel: t('Expand Station section'),
|
||||
collapseLabel: t('Collapse Station section'),
|
||||
@@ -78,9 +87,9 @@ const stationWords = computed(() => ({
|
||||
<template #badge><span id="station-badge" class="station-badge">{{ view ? view.title : '' }}</span></template>
|
||||
<template v-if="view">
|
||||
<div class="station-subject">{{ view.subject }}</div>
|
||||
<div class="station-modes" role="radiogroup" :aria-label="t('Mode')">
|
||||
<button id="station-automatic-btn" type="button" role="radio" class="station-mode" :aria-checked="String(!manual)" v-class-toggle="{ 'is-active': !manual }" @click="act('setStationMode', 'automatic')">{{ t('Automatic') }}</button>
|
||||
<button id="station-manual-btn" type="button" role="radio" class="station-mode" :aria-checked="String(manual)" v-class-toggle="{ 'is-active': manual }" @click="act('setStationMode', 'manual')">{{ t('Manual') }}</button>
|
||||
<div class="station-modes" role="radiogroup" :aria-label="t('Mode')" @keydown.left.prevent="stepMode" @keydown.right.prevent="stepMode" @keydown.up.prevent="stepMode" @keydown.down.prevent="stepMode">
|
||||
<button id="station-automatic-btn" type="button" role="radio" class="station-mode" :tabindex="manual ? -1 : 0" :aria-checked="String(!manual)" v-class-toggle="{ 'is-active': !manual }" @click="act('setStationMode', 'automatic')">{{ t('Automatic') }}</button>
|
||||
<button id="station-manual-btn" type="button" role="radio" class="station-mode" :tabindex="manual ? 0 : -1" :aria-checked="String(manual)" v-class-toggle="{ 'is-active': manual }" @click="act('setStationMode', 'manual')">{{ t('Manual') }}</button>
|
||||
</div>
|
||||
<p id="station-telemetry" class="station-telemetry" :data-tone="telemetryTone" role="status" aria-live="polite"><span class="station-telemetry-dot" aria-hidden="true"></span>{{ telemetryText }}</p>
|
||||
<p v-if="!manual && sunText" id="station-sun" class="station-note">{{ sunText }}</p>
|
||||
|
||||
Reference in new issue
Block a user