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



commit 825cc1beb21f661168b12ce1a41db772c4720fa7
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]