Skip to content

Commit 6154bfc

Browse files
committed
fix: address channel migration review
1 parent 1ee6044 commit 6154bfc

7 files changed

Lines changed: 33 additions & 20 deletions

File tree

src/frontend/components/SectorDelta/widgetRuntimeDefinition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export default {
1010
'track-state.snapshot',
1111
],
1212
ratePreset: 'static',
13+
channelRates: { 'track-state.snapshot': 25 },
1314
} satisfies WidgetRuntimeDefinition;

src/frontend/components/Standings/hooks/useSessionLapCount.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useSessionTimingSnapshot } from '@irdashies/context';
2+
import type { SessionTimingSnapshot } from '@irdashies/types';
23

34
const EMPTY = {
45
state: 0,
@@ -8,6 +9,13 @@ const EMPTY = {
89
timeTotal: 0,
910
timeRemaining: 0,
1011
greenFlagTimestamp: 0,
11-
};
12+
sessionType: undefined,
13+
isFixedLapRace: false,
14+
totalRaceLaps: 0,
15+
totalRaceTime: 0,
16+
adjustedRaceTime: 0,
17+
sessionNum: null,
18+
version: 0,
19+
} satisfies SessionTimingSnapshot;
1220

1321
export const useSessionLapCount = () => useSessionTimingSnapshot() ?? EMPTY;

src/frontend/components/Standings/hooks/useTrackTemperature.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { useMemo } from 'react';
22
import { useSessionBarSnapshot } from '@irdashies/context';
33

4+
type TemperatureUnit = 'Metric' | 'Imperial';
5+
46
interface UseTrackTemperatureOptions {
5-
airTempUnit?: 'Metric' | 'Imperial';
6-
trackTempUnit?: 'Metric' | 'Imperial';
7+
airTempUnit?: TemperatureUnit;
8+
trackTempUnit?: TemperatureUnit;
79
}
810

911
export const useTrackTemperature = (
@@ -15,24 +17,22 @@ export const useTrackTemperature = (
1517
const airTempVal = snapshot?.airTemp;
1618

1719
const trackTemp = useMemo(() => {
18-
const trackTemp = trackTempVal ?? 0;
19-
if (trackTemp === null || trackTemp === undefined) return '';
20+
if (trackTempVal === undefined) return '';
2021

2122
// Convert to Fahrenheit if Imperial unit is selected
2223
const displayTemp =
23-
trackTempUnit === 'Imperial' ? (trackTemp * 9) / 5 + 32 : trackTemp;
24+
trackTempUnit === 'Imperial' ? (trackTempVal * 9) / 5 + 32 : trackTempVal;
2425

2526
const unit = trackTempUnit === 'Imperial' ? 'F' : 'C';
2627
return `${displayTemp.toFixed(0)}°${unit}`;
2728
}, [trackTempVal, trackTempUnit]);
2829

2930
const airTemp = useMemo(() => {
30-
const airTemp = airTempVal ?? 0;
31-
if (airTemp === null || airTemp === undefined) return '';
31+
if (airTempVal === undefined) return '';
3232

3333
// Convert to Fahrenheit if Imperial unit is selected
3434
const displayTemp =
35-
airTempUnit === 'Imperial' ? (airTemp * 9) / 5 + 32 : airTemp;
35+
airTempUnit === 'Imperial' ? (airTempVal * 9) / 5 + 32 : airTempVal;
3636

3737
const unit = airTempUnit === 'Imperial' ? 'F' : 'C';
3838
return `${displayTemp.toFixed(0)}°${unit}`;

src/frontend/components/Weather/hooks/useTrackTemperature.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ export const useTrackTemperature = (
1515
const airTempVal = snapshot?.airTemp;
1616

1717
const trackTemp = useMemo(() => {
18-
const trackTemp = trackTempVal ?? 0;
18+
if (trackTempVal === undefined) return '';
1919
const displayTemp =
20-
trackTempUnit === 'Imperial' ? (trackTemp * 9) / 5 + 32 : trackTemp;
20+
trackTempUnit === 'Imperial' ? (trackTempVal * 9) / 5 + 32 : trackTempVal;
2121
const unit = trackTempUnit === 'Imperial' ? 'F' : 'C';
2222
return `${Math.round(displayTemp)}°${unit}`;
2323
}, [trackTempVal, trackTempUnit]);
2424

2525
const airTemp = useMemo(() => {
26-
const airTemp = airTempVal ?? 0;
26+
if (airTempVal === undefined) return '';
2727
const displayTemp =
28-
airTempUnit === 'Imperial' ? (airTemp * 9) / 5 + 32 : airTemp;
28+
airTempUnit === 'Imperial' ? (airTempVal * 9) / 5 + 32 : airTempVal;
2929
const unit = airTempUnit === 'Imperial' ? 'F' : 'C';
3030
return `${Math.round(displayTemp)}°${unit}`;
3131
}, [airTempVal, airTempUnit]);

src/frontend/context/CarSpeedStore/TopSpeedStoreUpdater.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ import { useTopSpeedStore } from './TopSpeedStore';
99
*/
1010
export const useTopSpeedStoreUpdater = (enabled: boolean) => {
1111
const snapshot = useSessionBarSnapshot();
12+
const hasSnapshot = snapshot !== undefined;
13+
const lastLapTopSpeed = snapshot?.lastLapTopSpeed ?? null;
14+
const sessionBestTopSpeed = snapshot?.sessionBestTopSpeed ?? null;
15+
const sessionNum = snapshot?.sessionNum ?? null;
1216

1317
useEffect(() => {
14-
if (!enabled || !snapshot) return;
18+
if (!enabled || !hasSnapshot) return;
1519
useTopSpeedStore.setState({
16-
lastLapTopSpeed: snapshot.lastLapTopSpeed,
17-
sessionBestTopSpeed: snapshot.sessionBestTopSpeed,
18-
sessionNum: snapshot.sessionNum,
20+
lastLapTopSpeed,
21+
sessionBestTopSpeed,
22+
sessionNum,
1923
});
20-
}, [enabled, snapshot]);
24+
}, [enabled, hasSnapshot, lastLapTopSpeed, sessionBestTopSpeed, sessionNum]);
2125
};
2226

2327
/**

test-data/telemetry/ai-race-10min.golden.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10325,7 +10325,7 @@
1032510325
},
1032610326
{
1032710327
"name": "track-state",
10328-
"schemaVersion": 1,
10328+
"schemaVersion": 2,
1032910329
"frameCount": 36000,
1033010330
"rollingHash": "382b2a33bff4f802f3cdcc9f2113f5f1a994f051489b1f32293540472c0a0fb6",
1033110331
"checkpoints": {

tools/telemetry-replay/track-state-probe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const createTrackStateProbe = (): ReplayProbe<TrackStateSnapshot> => {
2222
const processor = new TrackStateProcessor();
2323
return {
2424
name: 'track-state',
25-
schemaVersion: 1,
25+
schemaVersion: 2,
2626
variables: [
2727
'CamCarIdx',
2828
'CarIdxLapDistPct',

0 commit comments

Comments
 (0)