fix: Refs nested on the replay object aren't unwrapping when passed as props.

This commit is contained in:
voltsrage
2026-06-20 14:43:21 +08:00
parent 7cfc5567fd
commit e1c78b49f4
+34 -18
View File
@@ -21,7 +21,23 @@ import Skeleton from '@/components/ui/Skeleton.vue'
const route = useRoute() const route = useRoute()
const alertStore = useAlertStore() const alertStore = useAlertStore()
const { alerts } = storeToRefs(alertStore) const { alerts } = storeToRefs(alertStore)
const replay = useReplayControls() const {
isPaused,
speed,
progress,
formattedTime,
currentMs,
scenarioEndMs,
scenarioStartMs,
pause,
resume,
setSpeed,
jumpToTimestamp,
isAtOrBefore,
setScenarioBounds,
syncToEnd,
stopPlayback,
} = useReplayControls()
const encounter = ref(null) const encounter = ref(null)
const loading = ref(true) const loading = ref(true)
@@ -39,11 +55,11 @@ const openAlerts = computed(() =>
) )
const replayObservations = computed(() => const replayObservations = computed(() =>
observations.value.filter(o => replay.isAtOrBefore(o.recordedAt)), observations.value.filter(o => isAtOrBefore(o.recordedAt)),
) )
const replayNews2History = computed(() => const replayNews2History = computed(() =>
news2History.value.filter(h => replay.isAtOrBefore(h.calculatedAt)), news2History.value.filter(h => isAtOrBefore(h.calculatedAt)),
) )
function collectScenarioTimes() { function collectScenarioTimes() {
@@ -58,10 +74,10 @@ function syncReplayBounds() {
const times = collectScenarioTimes() const times = collectScenarioTimes()
if (!times.length) return if (!times.length) return
const atEnd = replay.currentMs.value >= replay.scenarioEndMs.value - 1_000 const atEnd = currentMs.value >= scenarioEndMs.value - 1_000
replay.setScenarioBounds(Math.min(...times), Math.max(...times)) setScenarioBounds(Math.min(...times), Math.max(...times))
if (atEnd || replay.scenarioEndMs.value === replay.scenarioStartMs.value) { if (atEnd || scenarioEndMs.value === scenarioStartMs.value) {
replay.syncToEnd() syncToEnd()
} }
} }
@@ -94,7 +110,7 @@ async function loadAll() {
function onSelectAlert(alert) { function onSelectAlert(alert) {
selectedAlert.value = alert selectedAlert.value = alert
replay.jumpToTimestamp(alert.triggeredAt) jumpToTimestamp(alert.triggeredAt)
} }
function jumpToNextAlert() { function jumpToNextAlert() {
@@ -106,7 +122,7 @@ function jumpToNextAlert() {
const alert = sorted[nextAlertIndex % sorted.length] const alert = sorted[nextAlertIndex % sorted.length]
selectedAlert.value = alert selectedAlert.value = alert
nextAlertIndex++ nextAlertIndex++
replay.jumpToTimestamp(alert.triggeredAt) jumpToTimestamp(alert.triggeredAt)
document.getElementById(`alert-row-${alert.id}`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) document.getElementById(`alert-row-${alert.id}`)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
document.getElementById('clinical-review')?.scrollIntoView({ behavior: 'smooth', block: 'start' }) document.getElementById('clinical-review')?.scrollIntoView({ behavior: 'smooth', block: 'start' })
@@ -117,7 +133,7 @@ usePolling(loadAll, 5_000)
watch(() => route.params.encounterId, () => { watch(() => route.params.encounterId, () => {
selectedAlert.value = null selectedAlert.value = null
nextAlertIndex = 0 nextAlertIndex = 0
replay.pause() pause()
loadAll() loadAll()
}) })
@@ -130,7 +146,7 @@ watch(openAlerts, (list) => {
watch([observations, news2History, alerts], syncReplayBounds, { deep: true }) watch([observations, news2History, alerts], syncReplayBounds, { deep: true })
onBeforeUnmount(() => replay.stopPlayback()) onBeforeUnmount(() => stopPlayback())
</script> </script>
<template> <template>
@@ -171,13 +187,13 @@ onBeforeUnmount(() => replay.stopPlayback())
<News2History v-if="replayNews2History.length" :history="replayNews2History" /> <News2History v-if="replayNews2History.length" :history="replayNews2History" />
<ReplayControls <ReplayControls
:alerts="openAlerts" :alerts="openAlerts"
:is-paused="replay.isPaused" :is-paused="isPaused"
:progress="replay.progress" :progress="progress"
:formatted-time="replay.formattedTime" :formatted-time="formattedTime"
:speed="replay.speed" :speed="speed"
@pause="replay.pause()" @pause="pause()"
@resume="replay.resume()" @resume="resume()"
@set-speed="replay.setSpeed" @set-speed="setSpeed"
@jump-to-alert="jumpToNextAlert" @jump-to-alert="jumpToNextAlert"
/> />
</div> </div>