From 6e7e99778e3cd03e743b319ba0b5643e41deb07d Mon Sep 17 00:00:00 2001 From: Svante Bengtson Date: Sat, 13 Jul 2024 17:50:22 +0200 Subject: [PATCH] show participant names for speed live when coming from servo --- src/components/SpeedLiveScore.vue | 10 +++++++--- src/views/DeviceStreamLive.vue | 26 ++++++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/SpeedLiveScore.vue b/src/components/SpeedLiveScore.vue index 3699394..5309c1f 100644 --- a/src/components/SpeedLiveScore.vue +++ b/src/components/SpeedLiveScore.vue @@ -27,10 +27,10 @@ {{ pool ?? '' }}
- {{ entry.participant.name }} + {{ entry?.participant?.name ?? names }}
@@ -66,6 +66,10 @@ const props = defineProps({ type: Object as PropType, default: () => null }, + names: { + type: String, + default: () => null + }, scoresheet: { type: Object as PropType | null>, default: () => null diff --git a/src/views/DeviceStreamLive.vue b/src/views/DeviceStreamLive.vue index b0ba334..ad42b26 100644 --- a/src/views/DeviceStreamLive.vue +++ b/src/views/DeviceStreamLive.vue @@ -19,6 +19,7 @@ :device-id="pools[`${row}:${col}`].deviceId" :cols="cols" :bg-url="poolBgUrl(pools[`${row}:${col}`].label)" + :names="poolNames(pools[`${row}:${col}`].label)" :theme="theme" /> import { computed, reactive, ref, watch } from 'vue' import { type DeviceStreamJudgeInfo, type DeviceStreamMarkAddedSubscription, useDeviceStreamMarkAddedSubscription } from '../graphql/generated' -import { type ScoreTally, type Mark } from '../helpers' +import { type ScoreTally, type Mark, formatList } from '../helpers' import { useDeviceStreamPools } from '../hooks/stream-pools' import { useHead } from '@vueuse/head' import { useRouteQuery } from '@vueuse/router' @@ -145,13 +146,18 @@ function markStreamWatcher (res: DeviceStreamMarkAddedSubscription | null | unde watch(markStreamSubscription.result, markStreamWatcher) watch(markStreamSubscriptionAlt.result, markStreamWatcher) -const poolBackgrounds = ref>([]) +const poolBackgrounds = ref>([]) function poolBgUrl (poolLabel: number | undefined) { if (poolLabel == null) return undefined return poolBackgrounds.value.find(pb => `${pb.poolLabel}` === `${poolLabel}`)?.bgUrl } +function poolNames (poolLabel: number | undefined) { + if (poolLabel == null) return undefined + return formatList(poolBackgrounds.value.find(pb => `${pb.poolLabel}` === `${poolLabel}`)?.names ?? []) +} + const hic = ref(settings.value.heatInfo) watch(() => settings.value.heatInfo, newHeatInfo => { hic.value = newHeatInfo }) @@ -162,10 +168,18 @@ watch(heatInfo.data, heatInfo => { poolBackgrounds.value = [] return } - poolBackgrounds.value = heatInfo.map(hi => ({ - poolLabel: hi.Station, - bgUrl: hi.TeamCountryFlagUrl || (hi.TeamCountryCode ? `/flags/${hi.TeamCountryCode.toLocaleLowerCase()}.svg` : undefined) - })) + poolBackgrounds.value = heatInfo.map(hi => { + const names = [] + for (const p of [1, 2, 3, 4]) { + let name = hi[`Part${p}`] + name = name.substring(0, name.length - (hi[`Part${p}_Last`] ?? '').length).trim() + if (name.length > 0) names.push(name) + } + return { + poolLabel: hi.Station, + bgUrl: hi.TeamCountryFlagUrl || (hi.TeamCountryCode ? `/flags/${hi.TeamCountryCode.toLocaleLowerCase()}.svg` : undefined), + names + }}) })