dateMenu: Only show forecasts

We currently always start with the current weather info, then append
forecasts. This is slightly confusing, as the only hint that the
first item is special is the past (and potentially "odd") time.

Stop doing that and base all items on forecasts.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1927
This commit is contained in:
Florian Müllner 2019-11-22 22:44:42 +01:00
parent b757f5c655
commit f6f373b0c2

View File

@ -309,26 +309,24 @@ class WeatherSection extends St.Button {
} }
_getInfos() { _getInfos() {
let info = this._weatherClient.info; let forecasts = this._weatherClient.info.get_forecast_list();
let forecasts = info.get_forecast_list();
let now = GLib.DateTime.new_now_local(); let now = GLib.DateTime.new_now_local();
let current = info; let current = GLib.DateTime.new_from_unix_local(0);
let infos = [info]; let infos = [];
for (let i = 0; i < forecasts.length; i++) { for (let i = 0; i < forecasts.length; i++) {
let [ok_, timestamp] = forecasts[i].get_value_update(); let [ok_, timestamp] = forecasts[i].get_value_update();
const datetime = GLib.DateTime.new_from_unix_local(timestamp); const datetime = GLib.DateTime.new_from_unix_local(timestamp);
if (now.difference(datetime) > 0) if (now.difference(datetime) > 0)
continue; // Ignore earlier forecasts continue; // Ignore earlier forecasts
[ok_, timestamp] = current.get_value_update(); if (datetime.difference(current) < GLib.TIME_SPAN_HOUR)
const currenttime = GLib.DateTime.new_from_unix_local(timestamp);
if (datetime.difference(currenttime) < GLib.TIME_SPAN_HOUR)
continue; // Enforce a minimum interval of 1h continue; // Enforce a minimum interval of 1h
current = forecasts[i]; if (infos.push(forecasts[i]) == MAX_FORECASTS)
if (infos.push(current) == MAX_FORECASTS)
break; // Use a maximum of five forecasts break; // Use a maximum of five forecasts
current = datetime;
} }
return infos; return infos;
} }