[gnome-maps] Update recent added time on re-visit



commit accbfcf83e2f08160e5512e8a9e3689a313532dc
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Jan 22 18:53:21 2014 +0100

    Update recent added time on re-visit
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722825

 src/mainWindow.js |    1 +
 src/placeStore.js |   17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 18aec45..742d543 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -118,6 +118,7 @@ const MainWindow = new Lang.Class({
         this._searchCompletion.connect('match-selected', (function(c, m, iter) {
             let place = m.get_value(iter, PlaceStore.Columns.PLACE);
             this.mapView.showNGotoLocation(place.location);
+            this._placeStore.addRecent(place);
         }).bind(this));
 
         this._searchCompletion.set_match_func(function(completion, key, iter) {
diff --git a/src/placeStore.js b/src/placeStore.js
index 0df236f..cee5e7b 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -83,8 +83,10 @@ const PlaceStore = new Lang.Class({
     },
 
     addRecent: function(place) {
-        if (this._exists(place, PlaceType.RECENT))
+        if (this._exists(place, PlaceType.RECENT)) {
+            this._updateAddTime(place);
             return;
+        }
 
         if (this._numRecent === this.recentLimit) {
             // Since we sort by added, the oldest recent will be
@@ -196,5 +198,18 @@ const PlaceStore = new Lang.Class({
             }
             return false;
         }).bind(this));
+    },
+
+    _updateAddTime: function(place) {
+        this.foreach((function(model, path, iter) {
+            let name = model.get_value(iter, Columns.NAME);
+
+            if (name === place.name) {
+                let updated = new Date().getTime();
+                model.set_value(iter, Columns.ADDED, updated);
+                this._store();
+                return;
+            }
+        }).bind(this));
     }
 });


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