[gnome-weather/wip/christopherdavis/use-find-nearest-city-instead-of-detached: 3/3] shared/world.js: don't use detached location from settings



commit 01bf03ab8cf805a5a2706a03c5615b42c020e41f
Author: Christopher Davis <brainblasted disroot org>
Date:   Thu Mar 21 16:50:20 2019 -0700

    shared/world.js: don't use detached location from settings

 src/shared/world.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/shared/world.js b/src/shared/world.js
index 07feade..1c7d8c6 100644
--- a/src/shared/world.js
+++ b/src/shared/world.js
@@ -103,9 +103,15 @@ var WorldModel = GObject.registerClass({
         let info = null;
         for (let i = locations.length - 1; i >= 0; i--) {
             let variant = locations[i];
-            let location = this._world.deserialize(variant);
-
-            info = this._addLocationInternal(location, false);
+            let world = this._world.deserialize(variant);
+            if (world != null) {
+                let coords = world.get_coords();
+                let location = this._world.find_nearest_city(coords[0], coords[1]);
+
+                info = this._addLocationInternal(location, false);
+            } else {
+                log('Failed to deserialize location from GVariant:' + variant.print(true));
+            }
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]