[gnome-weather/wip/hadess/use-libgeoclue-portal: 9/9] currentLocationController: Keep compatibility with older geoclue




commit 16c9005f7597d9ea94f9cc0e79a546139f3bc58b
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Nov 9 20:21:11 2021 +0100

    currentLocationController: Keep compatibility with older geoclue
    
    Geoclue.Simple.new_with_thresholds isn't in a released geoclue
    version yet, so keep the old code around until we can rely on
    it.

 src/app/currentLocationController.js | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/src/app/currentLocationController.js b/src/app/currentLocationController.js
index 57dace9..8c5d1f5 100644
--- a/src/app/currentLocationController.js
+++ b/src/app/currentLocationController.js
@@ -44,14 +44,23 @@ var CurrentLocationController = class CurrentLocationController {
 
     _startGeolocationService() {
         this._processStarted = true;
-        Geoclue.Simple.new_with_thresholds(pkg.name,
-                                           Geoclue.AccuracyLevel.CITY,
-                                           0, /* time threshold */
-                                           100, /* distance threshold */
-                                           null,
-                                           (object, result) => {
-                                               this._onSimpleReady(object, result)
-                                           });
+        if (Geoclue.Simple.new_with_thresholds) {
+            Geoclue.Simple.new_with_thresholds(pkg.name,
+                                               Geoclue.AccuracyLevel.CITY,
+                                               0, /* time threshold */
+                                               100, /* distance threshold */
+                                               null,
+                                               (object, result) => {
+                                                   this._onSimpleReady(object, result)
+                                               });
+        } else {
+            Geoclue.Simple.new(pkg.name,
+                               Geoclue.AccuracyLevel.CITY,
+                               null,
+                               (object, result) => {
+                                   this._onSimpleReady(object, result)
+                               });
+        }
     }
 
     _geoLocationFailed(e) {
@@ -71,6 +80,11 @@ var CurrentLocationController = class CurrentLocationController {
             return;
         }
 
+        if (!Geoclue.Simple.new_with_thresholds) {
+            let client = this._simple.get_client();
+            client.distance_threshold = 100;
+        }
+
         this._findLocation();
     }
 


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