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

@@ -249,11 +249,30 @@ function getForecastConditionDescription(code: number | null, language: Language
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 === "snow") return translate(language, "weather.currentSnow");
if (condition === "rain") return translate(language, "weather.currentRain");
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);
if (forecastDescription) return forecastDescription;
if ((station.humidity ?? 0) >= 90) return translate(language, "weather.humid");