diff --git a/app/pages/control.vue b/app/pages/control.vue index 93a5173..7e4bf36 100644 --- a/app/pages/control.vue +++ b/app/pages/control.vue @@ -9,7 +9,7 @@ import { } from '@sit-onyx/icons' import { scenarioLabel } from '#shared/live' import type { ScenarioPreset, ScenarioState } from '#shared/types' -import { apiErrorMessage } from '~/utils/api-error' +import { apiErrorMessage, apiErrorStatus } from '~/utils/api-error' import { formatDateTime } from '~/utils/format' useHead({ title: 'Presenter control — PulseCast' }) @@ -23,7 +23,14 @@ const busy = ref('') const message = ref('') const errorMessage = ref('') -const current = computed(() => submitted.value ?? live.scenario ?? initialScenario.value ?? null) +const current = computed(() => { + const liveState = live.scenario + const local = submitted.value + if (!liveState) return local ?? initialScenario.value ?? null + if (!local) return liveState + // A remote presenter can move the stage on; always show the newer version. + return liveState.version >= local.version ? liveState : local +}) const activeId = computed(() => current.value?.scenario.scenario ?? '') const presetList = computed(() => presets.value ?? []) @@ -50,9 +57,7 @@ async function apply(preset: ScenarioPreset) { } catch (error) { errorMessage.value = apiErrorMessage(error, 'The scenario change failed. Check the Go API and control credentials.') + - (String((error as { status?: number }).status) === '401' - ? ' Reload this page to sign in again.' - : '') + (apiErrorStatus(error) === 401 ? ' Reload this page to sign in again.' : '') } finally { busy.value = '' }