Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/frontend/components/Weather/Weather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { useTrackTemperature } from './hooks/useTrackTemperature';
import { useTrackWeather } from './hooks/useTrackWeather';
import { WeatherTemp } from './WeatherTemp/WeatherTemp';
import { WeatherTrackWetness } from './WeatherTrackWetness/WeatherTrackWetness';
import { WeatherTrackRubbered } from './WeatherTrackRubbered/WeatherTrackRubbered';
import { WindDirection } from './WindDirection/WindDirection';
import { useTrackRubberedState } from './hooks/useTrackRubberedState';

export const Weather = () => {
const [parent] = useAutoAnimate();
const weather = useTrackWeather();
const trackTemp = useTrackTemperature();
const windSpeed = weather.windVelocity;
const relativeWindDirection = (weather.windDirection ?? 0) - (weather.windYaw ?? 0);
const trackRubbered = useTrackRubberedState();

return (
<div
Expand All @@ -22,6 +25,7 @@ export const Weather = () => {
<WeatherTemp title="Air" value={trackTemp.airTemp} />
<WindDirection speedMs={windSpeed} direction={relativeWindDirection} />
<WeatherTrackWetness trackMoisture={weather.trackMoisture} />
<WeatherTrackRubbered trackRubbered={trackRubbered} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Path } from '@phosphor-icons/react';
interface Props {
trackRubbered: string | undefined;
}

export const WeatherTrackRubbered: React.FC<Props> = ({ trackRubbered }) => {
return (
<div className="bg-slate-800/70 p-2 rounded-sm">
<div className="flex flex-row items-center gap-6">
<span className="text-m text-gray-400 mr-1"><Path /></span>
<span className="text-sm">{trackRubbered ?? 'N/A'}</span>
</div>
</div>
);
};
12 changes: 12 additions & 0 deletions src/frontend/components/Weather/hooks/useTrackRubberedState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useSessionStore } from '@irdashies/context';
import { useStore } from 'zustand';

export const useTrackRubberedState = () => {
return useStore(
useSessionStore,
(state) =>
state.session?.SessionInfo?.Sessions?.find(
(session) => session.SessionNum === 0
Copy link

@xikxp1 xikxp1 May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point sorry I missed that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault for submitting unread code ;) I guess the effect is that you get stale track state for practice during qualy and race. I'll try to fix and submit a new PR later today when I get home

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at this, and the plot seriously thickened:

  • State of every session can be set specifically or "carry over" from the previous one, the state then is literally "carry over"
  • Officials are set as "carry over", AI and hosted can be set to specific states per session or carry over.
  • I think it's better to know the initial state than to show "carry over".
  • So as it is now it works perfectly for official races.
  • To make it work for hosteds we would need logic to show the "last non carry over state". But this is not as trivial as just memoizing the latest valid state and showing the latest non-carry one, because what happens to someone who joins in qualy? we need to look back into past sessions to find a valid one.

I almost regret submitting this now 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm stupid it´s a very easy fix, I'll submit another PR with a sane handling of this

)?.SessionTrackRubberState
);
};