Skip to content

Commit

Permalink
fix(conditions): trying to pad null winddirection when speed is calm (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceh91 committed Mar 5, 2024
1 parent b8c79aa commit b68fc6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- "**.js"
- "**.ts"
- "**.tsx"
- "**.test.ts"
- "**.json"
- "**.yml"
Expand All @@ -17,6 +18,7 @@ on:
paths:
- "**.js"
- "**.ts"
- "**.tsx"
- "**.test.ts"
- "**.json"
- "**.yml"
Expand Down
10 changes: 5 additions & 5 deletions src/display/components/weather/conditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ export function Conditions(props: ConditionsProp) {
);

const formattedWind = useMemo(() => {
// handle "calm" or wind less than 2kmh
if (!windSpeedValue || windSpeedValue === CONDITIONS_WIND_SPEED_CALM || Number(windSpeedValue) < 2)
return CONDITIONS_WIND_SPEED_CALM;

const speed = windSpeedValue ?? "";
const direction = windDirection.padStart(3);

// gust is a different format
// gust is a different format (omits units)
if (windGust) return `${direction} ${speed}G${windGust.value} `;

// handle "calm" or wind less than 2kmh
if (!windSpeedValue || windSpeedValue === CONDITIONS_WIND_SPEED_CALM || Number(windSpeedValue) < 2)
return CONDITIONS_WIND_SPEED_CALM.padEnd(11);

return `${direction}${`${speed} KMH`.padStart(8)}`;
}, [observedDateTime]);

Expand Down

0 comments on commit b68fc6a

Please sign in to comment.