fix: prefer hybrid cloud cover in hero

This commit is contained in:
zv
2026-06-14 11:05:04 +02:00
parent a9b0c65527
commit 2d424655e5
2 changed files with 28 additions and 2 deletions

View File

@@ -80,7 +80,14 @@ export function WeatherHero({ station, currentWeather, currentWeatherLoading = f
: devEffectOverride === "rain" || devEffectOverride === "none" : devEffectOverride === "rain" || devEffectOverride === "none"
? false ? false
: currentWeather?.condition === "thunderstorm"; : currentWeather?.condition === "thunderstorm";
const weatherDescription = getWeatherDescription(displayedStation, language, currentWeather?.condition, currentForecastWeatherCode); const weatherDescription = getWeatherDescription(
displayedStation,
language,
currentWeather?.condition,
currentWeather?.weatherCode,
currentWeather?.cloudCover,
currentForecastWeatherCode,
);
useEffect(() => { useEffect(() => {
if (process.env.NODE_ENV !== "development") return; if (process.env.NODE_ENV !== "development") return;

View File

@@ -249,11 +249,30 @@ function getForecastConditionDescription(code: number | null, language: Language
return null; return null;
} }
export function getWeatherDescription(station: SynopStation, language: Language = "pl", condition?: CurrentWeatherCondition, forecastWeatherCode?: number | null) { function getCloudCoverDescription(cloudCover: number | null | undefined, language: Language) {
if (cloudCover === null || cloudCover === undefined) return null;
if (cloudCover >= 75) return translate(language, "forecast.condition.cloudy");
if (cloudCover >= 25) return translate(language, "forecast.condition.partlyCloudy");
return null;
}
export function getWeatherDescription(
station: SynopStation,
language: Language = "pl",
condition?: CurrentWeatherCondition,
currentWeatherCode?: number | null,
currentCloudCover?: number | null,
forecastWeatherCode?: number | null,
) {
if (condition === "thunderstorm") return translate(language, "weather.thunderstorm"); if (condition === "thunderstorm") return translate(language, "weather.thunderstorm");
if (condition === "snow") return translate(language, "weather.currentSnow"); if (condition === "snow") return translate(language, "weather.currentSnow");
if (condition === "rain") return translate(language, "weather.currentRain"); if (condition === "rain") return translate(language, "weather.currentRain");
if ((station.windSpeed ?? 0) >= 8) return translate(language, "weather.strongWind"); if ((station.windSpeed ?? 0) >= 8) return translate(language, "weather.strongWind");
const currentDescription = getForecastConditionDescription(currentWeatherCode ?? null, language);
const cloudCoverDescription = getCloudCoverDescription(currentCloudCover, language);
if (cloudCoverDescription && (currentWeatherCode === null || currentWeatherCode === undefined || currentWeatherCode === 0)) return cloudCoverDescription;
if (currentDescription) return currentDescription;
if (cloudCoverDescription) return cloudCoverDescription;
const forecastDescription = getForecastConditionDescription(forecastWeatherCode ?? null, language); const forecastDescription = getForecastConditionDescription(forecastWeatherCode ?? null, language);
if (forecastDescription) return forecastDescription; if (forecastDescription) return forecastDescription;
if ((station.humidity ?? 0) >= 90) return translate(language, "weather.humid"); if ((station.humidity ?? 0) >= 90) return translate(language, "weather.humid");