[gnome-maps] Routing: Remove latest place on failure



commit 20a0ee8373216ece0e0b077f8f4ac17926817e97
Author: ndesh26 <nayan26deshmukh gmail com>
Date:   Mon Feb 29 19:39:21 2016 +0530

    Routing: Remove latest place on failure
    
    If a new entry is added to exixting route which results in
    route not found then revert back to previous route and set the place
    of the point to null. To implement this Add a latest field to routeQuery
    which keeps the latest point added. and in routeService if route
    is not found set latest.place to null.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762483

 src/routeQuery.js   |   10 +++++++++-
 src/routeService.js |   12 ++++++++++--
 src/sidebar.js      |    3 +--
 3 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/routeQuery.js b/src/routeQuery.js
index 4ae8264..43e38f6 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -108,6 +108,10 @@ const RouteQuery = new Lang.Class({
         });
     },
 
+    get latest() {
+        return this._latest;
+    },
+
     _init: function(args) {
         this.parent(args);
         this._points = [];
@@ -130,16 +134,19 @@ const RouteQuery = new Lang.Class({
                 }
             }
             this.notify('points');
+            this._latest = point;
         }).bind(this));
+        this._latest = point;
         this.notify('points');
         this.emit('point-added', point, index);
-
         return point;
     },
 
     removePoint: function(index) {
         let removedPoints = this._points.splice(index, 1);
         let point = removedPoints ? removedPoints[0] : null;
+        if (point === this._latest)
+            this._latest = null;
 
         if (point) {
             this.notify('points');
@@ -162,6 +169,7 @@ const RouteQuery = new Lang.Class({
         this._points.forEach(function(point) {
             point.place = null;
         });
+        this._latest = null;
         this.thaw_notify();
         this.emit('reset');
     },
diff --git a/src/routeService.js b/src/routeService.js
index 8d6b986..31ad061 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -88,14 +88,22 @@ const GraphHopper = new Lang.Class({
                 let result = this._parseMessage(message);
                 if (!result) {
                     Application.notificationManager.showMessage(_("No route found."));
-                    this.route.reset();
+                    if (this.query.latest)
+                        this.query.latest.place = null;
+                    else
+                        this.route.reset();
+
                 } else {
                     let route = this._createRoute(result.paths[0]);
                     this.route.update(route);
                 }
             } catch(e) {
                 Application.notificationManager.showMessage(_("Route request failed."));
-                log(e);
+                Utils.debug(e);
+                if (this.query.latest)
+                    this.query.latest.place = null;
+                else
+                    this.route.reset();
             }
         }).bind(this));
     },
diff --git a/src/sidebar.js b/src/sidebar.js
index f20d535..64ec5e6 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -155,7 +155,6 @@ const Sidebar = new Lang.Class({
 
         route.connect('reset', (function() {
             this._clearInstructions();
-            this._instructionStack.visible_child = this._instructionWindow;
 
             let length = this._entryList.get_children().length;
             for (let index = 1; index < (length - 1); index++) {
@@ -176,7 +175,6 @@ const Sidebar = new Lang.Class({
 
         route.connect('update', (function() {
             this._clearInstructions();
-            this._instructionStack.visible_child = this._instructionWindow;
 
             if (this._storeRouteTimeoutId)
                 this._cancelStore();
@@ -221,6 +219,7 @@ const Sidebar = new Lang.Class({
         let listBox = this._instructionList;
         listBox.forall(listBox.remove.bind(listBox));
 
+        this._instructionStack.visible_child = this._instructionWindow;
         this._timeInfo.label = '';
         this._distanceInfo.label = '';
     },


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