Weather: daily strip shows upcoming days, not today again
Today is already shown big at the top (temp/description/date), so having it repeat as the first column of the daily strip was redundant. forecast_days now means "how many upcoming days", fetching one extra day from the API and dropping today from the strip -- high_today/low_today still come from that dropped day, unaffected. Verified live: on a Saturday, the strip now starts at Sunday instead of repeating Saturday.
This commit is contained in:
1 parent
7601f746fe
commit
11c03c86b1
1 file changed
+11
-3
+11
-3
@@ -96,7 +96,11 @@ class WeatherScreen(Screen):
|
||||
"current": "temperature_2m,apparent_temperature,weather_code",
|
||||
"daily": "weather_code,temperature_2m_max,temperature_2m_min,precipitation_probability_max",
|
||||
"hourly": "temperature_2m",
|
||||
"forecast_days": forecast_days,
|
||||
# +1: forecast_days is "how many upcoming days in the daily
|
||||
# strip", and today itself is dropped from that strip below
|
||||
# (already shown big up top) -- so fetching just
|
||||
# forecast_days would leave the strip one day short.
|
||||
"forecast_days": forecast_days + 1,
|
||||
"timezone": "auto",
|
||||
},
|
||||
timeout=HTTP_TIMEOUT,
|
||||
@@ -127,6 +131,10 @@ class WeatherScreen(Screen):
|
||||
"low": daily["temperature_2m_min"][i],
|
||||
})
|
||||
|
||||
high_today = days[0]["high"] if days else None
|
||||
low_today = days[0]["low"] if days else None
|
||||
days = days[1:] # drop today -- already shown big up top
|
||||
|
||||
rain_chance = None
|
||||
probs = daily.get("precipitation_probability_max") or []
|
||||
if probs and probs[0] is not None:
|
||||
@@ -148,8 +156,8 @@ class WeatherScreen(Screen):
|
||||
"description": description,
|
||||
"kind": kind,
|
||||
"days": days,
|
||||
"high_today": days[0]["high"] if days else None,
|
||||
"low_today": days[0]["low"] if days else None,
|
||||
"high_today": high_today,
|
||||
"low_today": low_today,
|
||||
"rain_chance": rain_chance,
|
||||
"hourly_today": hourly_today,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user