diff --git a/src/main.tsx b/src/main.tsx index 73783e2..069bea2 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,6 +1,6 @@ import Fastify from 'fastify' import { Database } from './database.js'; -import { MatchResponse, PlayerResponse, PubgApi } from './pubg-api.js'; +import { Asset, MatchResponse, PlayerResponse, PubgApi } from './pubg-api.js'; import { Mutex } from 'async-mutex'; import { render, renderToStringAsync } from 'preact-render-to-string'; import { h, Fragment } from 'preact'; @@ -57,8 +57,12 @@ function getBotCount(match: MatchResponse) { return { playerCount, botCount, humanCount: playerCount - botCount }; } -function getChickenDinnerUrl(match: MatchResponse, player: PlayerResponse['data'][0]) { +function getTelemetry(match: MatchResponse) { const asset = match.included.find(i => i.type === 'asset')!; + return asset!; +} + +function getChickenDinnerUrl(asset: Asset, player: PlayerResponse['data'][0]) { const url = asset.attributes.URL.substring('https://telemetry-cdn.pubg.com/bluehole-pubg/'.length).replace('-telemetry.json', ''); return `https://chickendinner.gg/${url}?follow=${player.attributes.name}`; } @@ -101,7 +105,8 @@ li a { padding: 0 5px; } var map = PubgApi.mapName(m.data.attributes.mapName); var rank = getRank(m, player.id); var count = getBotCount(m); - const date = dayjs(m.data.attributes.createdAt).add(m.data.attributes.duration, 's'); + const telemetry = getTelemetry(m); + const date = dayjs(telemetry.attributes.createdAt); return