fix: prefer hybrid cloud cover in hero
This commit is contained in:
@@ -80,7 +80,14 @@ export function WeatherHero({ station, currentWeather, currentWeatherLoading = f
|
||||
: devEffectOverride === "rain" || devEffectOverride === "none"
|
||||
? false
|
||||
: currentWeather?.condition === "thunderstorm";
|
||||
const weatherDescription = getWeatherDescription(displayedStation, language, currentWeather?.condition, currentForecastWeatherCode);
|
||||
const weatherDescription = getWeatherDescription(
|
||||
displayedStation,
|
||||
language,
|
||||
currentWeather?.condition,
|
||||
currentWeather?.weatherCode,
|
||||
currentWeather?.cloudCover,
|
||||
currentForecastWeatherCode,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (process.env.NODE_ENV !== "development") return;
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user