dateMenu: Move weather forecast validity check
Commit b779f6f728
added a check to filter out invalid weather forecasts.
However the check is currently done when creating UI for the forecasts,
which means we end up with fewer forecasts than we could display if any
forecasts are invalid.
We can avoid that issue by checking the validity while collecting the
forecasts, so do that instead.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1927
This commit is contained in:
parent
f6f373b0c2
commit
e72c38b5ab
@ -315,7 +315,10 @@ class WeatherSection extends St.Button {
|
|||||||
let current = GLib.DateTime.new_from_unix_local(0);
|
let current = GLib.DateTime.new_from_unix_local(0);
|
||||||
let infos = [];
|
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();
|
const [valid, timestamp] = forecasts[i].get_value_update();
|
||||||
|
if (!valid || timestamp === 0)
|
||||||
|
continue; // 0 means 'never updated'
|
||||||
|
|
||||||
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
|
||||||
@ -340,9 +343,7 @@ class WeatherSection extends St.Button {
|
|||||||
|
|
||||||
let col = 0;
|
let col = 0;
|
||||||
infos.forEach(fc => {
|
infos.forEach(fc => {
|
||||||
const [valid, timestamp] = fc.get_value_update();
|
const [valid_, timestamp] = fc.get_value_update();
|
||||||
if (!valid || timestamp === 0)
|
|
||||||
return; // 0 means 'never updated'
|
|
||||||
let timeStr = Util.formatTime(new Date(timestamp * 1000), {
|
let timeStr = Util.formatTime(new Date(timestamp * 1000), {
|
||||||
timeOnly: true,
|
timeOnly: true,
|
||||||
ampm: false,
|
ampm: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user