Skip to content

Commit d342a0e

Browse files
committed
Convert createdTimestamp (bigint -> string) to isoString
1 parent 9180d0f commit d342a0e

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

frontend/src/components/match/GameEventItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {computed} from "vue";
33
import TeamBadge from "@/components/common/TeamBadge.vue";
44
import {gameEventName} from "@/helpers/texts";
55
import type {GameEventJson} from "@/proto/state/ssl_gc_game_event_pb";
6-
import {formatTimestamp, gameEventForTeam} from "@/helpers";
6+
import {formatTimestamp, gameEventForTeam, usToTimestampJson} from "@/helpers";
77
import OriginIcon from "@/components/common/OriginIcon.vue";
88
99
const props = defineProps<{
@@ -24,7 +24,7 @@ const origins = computed(() => {
2424
2525
const time = computed(() => {
2626
if (props.gameEvent.createdTimestamp) {
27-
return formatTimestamp(props.gameEvent.createdTimestamp)
27+
return formatTimestamp(usToTimestampJson(props.gameEvent.createdTimestamp))
2828
}
2929
return undefined
3030
})

frontend/src/components/match/GameEventProposalGroupItem.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {gameEventName} from "@/helpers/texts";
44
import type {ProposalGroupJson} from "@/proto/state/ssl_gc_state_pb";
55
import type {GameEventJson} from "@/proto/state/ssl_gc_game_event_pb";
66
import TeamBadge from "@/components/common/TeamBadge.vue";
7-
import {formatTimestamp, gameEventForTeam} from "@/helpers";
7+
import {formatTimestamp, gameEventForTeam, usToTimestampJson} from "@/helpers";
88
import OriginIcon from "@/components/common/OriginIcon.vue";
99
1010
const props = defineProps<{
@@ -44,9 +44,9 @@ const origins = computed(() => {
4444
4545
const createdTimestamp = computed(() => {
4646
if (props.acceptedGameEvent) {
47-
return props.acceptedGameEvent.createdTimestamp
47+
return usToTimestampJson(props.acceptedGameEvent.createdTimestamp!)
4848
}
49-
return proposals.value?.flatMap(p => p.gameEvent?.createdTimestamp).sort()[0]
49+
return proposals.value?.flatMap(p => usToTimestampJson(p.gameEvent?.createdTimestamp || 0)).sort()[0]
5050
})
5151
5252
const time = computed(() => {

frontend/src/components/match/GameEvents.vue

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {GameEventJson} from "@/proto/state/ssl_gc_game_event_pb";
88
import GameEventDetailsTree from "@/components/match/GameEventDetailsTree.vue";
99
import type {ControlApi} from "@/providers/controlApi";
1010
import type {TimestampJson} from "@bufbuild/protobuf/wkt";
11-
import {timestampJsonMs} from "@/helpers";
11+
import {timestampJsonMs, usToTimestampJson} from "@/helpers";
1212
1313
const store = useMatchStateStore()
1414
const control = inject<ControlApi>('control-api')
@@ -51,7 +51,7 @@ const gameEventItems = computed(() => {
5151
} else {
5252
const item: GameEventWrappedItem = {
5353
id: gameEvent.id!,
54-
timestamp: gameEvent.createdTimestamp!,
54+
timestamp: usToTimestampJson(gameEvent.createdTimestamp!),
5555
gameEvent: gameEvent,
5656
}
5757
items.push(item)
@@ -116,11 +116,11 @@ const acceptGroup = (groupId: string) => {
116116

117117
<template>
118118
<q-tree
119-
v-if="gameEventItems.length > 0"
120-
:nodes="nodes"
121-
node-key="id"
122-
dense
123-
class="full-width"
119+
v-if="gameEventItems.length > 0"
120+
:nodes="nodes"
121+
node-key="id"
122+
dense
123+
class="full-width"
124124
>
125125
<!--suppress VueUnrecognizedSlot -->
126126
<template #header-accept="prop: Prop">
@@ -130,38 +130,38 @@ const acceptGroup = (groupId: string) => {
130130
</q-item-section>
131131
<q-item-section>
132132
<q-btn
133-
dense
134-
color="primary"
135-
label="Accept"
136-
@click="() => acceptGroup(prop.node.proposalGroup?.id!)"
137-
v-if="!prop.node.proposalGroup?.accepted"/>
133+
dense
134+
color="primary"
135+
label="Accept"
136+
@click="() => acceptGroup(prop.node.proposalGroup?.id!)"
137+
v-if="!prop.node.proposalGroup?.accepted"/>
138138
</q-item-section>
139139
</q-item>
140140
</template>
141141

142142
<!--suppress VueUnrecognizedSlot -->
143143
<template #header-proposal="prop: Prop">
144144
<GameEventProposalGroupItem
145-
class="full-width"
146-
:proposal-group="prop.node.proposalGroup!"
147-
:group-id="prop.node.id"
148-
:accepted-game-event="prop.node.gameEvent!"
145+
class="full-width"
146+
:proposal-group="prop.node.proposalGroup!"
147+
:group-id="prop.node.id"
148+
:accepted-game-event="prop.node.gameEvent!"
149149
/>
150150
</template>
151151

152152
<!--suppress VueUnrecognizedSlot -->
153153
<template #header-game-event="prop: Prop">
154154
<GameEventItem
155-
class="full-width"
156-
:game-event="prop.node.gameEvent!"
155+
class="full-width"
156+
:game-event="prop.node.gameEvent!"
157157
/>
158158
</template>
159159

160160
<!--suppress VueUnrecognizedSlot -->
161161
<template v-slot:header-game-event-details="prop: Prop">
162162
<GameEventDetailsTree
163-
class="full-width"
164-
:game-event="prop.node.gameEvent!"
163+
class="full-width"
164+
:game-event="prop.node.gameEvent!"
165165
/>
166166
</template>
167167
</q-tree>

frontend/src/helpers/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,10 @@ export const timestampJsonMs = function (timestamp: TimestampJson): number {
139139
export const formatTimestamp = function (timestamp: TimestampJson): string {
140140
return dayjs(timestamp).format("MMM, DD YYYY HH:mm:ss,SSS")
141141
}
142+
143+
export const usToTimestampJson = function (timestampUs: number | string): TimestampJson {
144+
if (typeof timestampUs === 'string') {
145+
return new Date(Number(BigInt(timestampUs) / BigInt(1000))).toISOString()
146+
}
147+
return new Date(timestampUs / 1000).toISOString()
148+
}

0 commit comments

Comments
 (0)