[gnome-maps] placeEntry: Don't notify when re-setting for routing



commit baaf0afd3424ddc4d032ceebeccd35df025009d4
Author: Marcus Lundblad <ml update uu se>
Date:   Sat Aug 24 12:37:17 2019 +0200

    placeEntry: Don't notify when re-setting for routing
    
    Don't notify place update when setting the same place
    again for entries attached to the routing entries.
    
    Fixes #195

 src/placeEntry.js | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 649a4ca..88cb1fa 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -57,6 +57,13 @@ var PlaceEntry = GObject.registerClass({
         if (!this._place && !p)
             return;
 
+        /* if this entry belongs to a routing query entry, don't notify when
+         * setting the same place, otherwise it will trigger twice when
+         * initiating from the context menu
+         */
+        if (!this._matchRoute && this._place && p && this._locEquals(this._place, p))
+            return;
+
         if (p) {
             if (p.name) {
                 this._placeText = p.name;
@@ -147,6 +154,14 @@ var PlaceEntry = GObject.registerClass({
         }
     }
 
+    _locEquals(placeA, placeB) {
+        if (!placeA.location || !placeB.location)
+            return false;
+
+        return (placeA.location.latitude === placeB.location.latitude &&
+                placeA.location.longitude === placeB.location.longitude);
+    }
+
     _createPopover(numVisible, maxChars) {
         let popover = new PlacePopover.PlacePopover({ num_visible:   numVisible,
                                                       relative_to:   this,


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