[gnome-shell] dateMenu: Only show forecasts
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dateMenu: Only show forecasts
- Date: Sat, 23 Nov 2019 00:23:25 +0000 (UTC)
commit f6f373b0c222ddd76ffa02c1c60f97b7468c4153
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 22 22:44:42 2019 +0100
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
js/ui/dateMenu.js | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index ec75653d87..a081c12f5b 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -309,26 +309,24 @@ class WeatherSection extends St.Button {
}
_getInfos() {
- let info = this._weatherClient.info;
- let forecasts = info.get_forecast_list();
+ let forecasts = this._weatherClient.info.get_forecast_list();
let now = GLib.DateTime.new_now_local();
- let current = info;
- let infos = [info];
+ let current = GLib.DateTime.new_from_unix_local(0);
+ let infos = [];
for (let i = 0; i < forecasts.length; i++) {
let [ok_, timestamp] = forecasts[i].get_value_update();
const datetime = GLib.DateTime.new_from_unix_local(timestamp);
if (now.difference(datetime) > 0)
continue; // Ignore earlier forecasts
- [ok_, timestamp] = current.get_value_update();
- const currenttime = GLib.DateTime.new_from_unix_local(timestamp);
- if (datetime.difference(currenttime) < GLib.TIME_SPAN_HOUR)
+ if (datetime.difference(current) < GLib.TIME_SPAN_HOUR)
continue; // Enforce a minimum interval of 1h
- current = forecasts[i];
- if (infos.push(current) == MAX_FORECASTS)
+ if (infos.push(forecasts[i]) == MAX_FORECASTS)
break; // Use a maximum of five forecasts
+
+ current = datetime;
}
return infos;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]