WatchFacePineTimeStyle: Fix conditional in weather display (#1965)

Since returning a valid weather is always considered an updated value,
if the current weather is empty, the face will attempt to display the
temperature and icon as empty values, rather than clearing the labels.
This commit is contained in:
Victor Kareh 2024-01-14 16:37:26 -05:00 committed by GitHub
parent 0503248a25
commit 264b5bed43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -540,7 +540,6 @@ void WatchFacePineTimeStyle::Refresh() {
} }
currentWeather = weatherService.Current(); currentWeather = weatherService.Current();
if (currentWeather.IsUpdated()) { if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get(); auto optCurrentWeather = currentWeather.Get();
if (optCurrentWeather) { if (optCurrentWeather) {
@ -551,12 +550,10 @@ void WatchFacePineTimeStyle::Refresh() {
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0); temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
lv_label_set_text_fmt(temperature, "%d°", temp); lv_label_set_text_fmt(temperature, "%d°", temp);
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId)); lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
lv_obj_realign(temperature);
lv_obj_realign(weatherIcon);
}
} else { } else {
lv_label_set_text(temperature, "--"); lv_label_set_text(temperature, "--");
lv_label_set_text(weatherIcon, Symbols::ban); lv_label_set_text(weatherIcon, Symbols::ban);
}
lv_obj_realign(temperature); lv_obj_realign(temperature);
lv_obj_realign(weatherIcon); lv_obj_realign(weatherIcon);
} }