polish: control page follows remote scenario versions
Prefer the newer SSE scenario over a local POST response, and use the shared error status helper.
This commit is contained in:
1 parent
233fdbf66c
commit
feb1f51015
1 file changed
+10
-5
+10
-5
@@ -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 = ''
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user