[gnome-maps/wip/favorites: 8/9] PlaceStore: Add addPlace method



commit cdd1057718789beb668c85f060931ec8fc6a7efa
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Sat Nov 22 00:56:34 2014 +0100

    PlaceStore: Add addPlace method
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722102

 src/placeStore.js         |   14 +++++++++++---
 src/searchResultBubble.js |    3 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/placeStore.js b/src/placeStore.js
index 43e0367..3723714 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -89,9 +89,10 @@ const PlaceStore = new Lang.Class({
         this._store();
     },
 
-    addFavorite: function(place) {
-        if (this.exists(place.osm_id, PlaceType.FAVORITE))
+    _addFavorite: function(place) {
+        if (this.exists(place.osm_id, PlaceType.FAVORITE)) {
             return;
+        }
 
         if (this.exists(place.osm_id, PlaceType.RECENT)) {
             this._removeIf((function(model, iter) {
@@ -102,7 +103,7 @@ const PlaceStore = new Lang.Class({
         this._addPlace(place, PlaceType.FAVORITE);
     },
 
-    addRecent: function(place) {
+    _addRecent: function(place) {
         if (this.exists(place.osm_id, PlaceType.RECENT)) {
             this._updatePlace(place);
             return;
@@ -154,6 +155,13 @@ const PlaceStore = new Lang.Class({
         }
     },
 
+    addPlace: function(place, type) {
+        if (type === PlaceType.FAVORITE)
+            this._addFavorite(place, type);
+        else if (type === PlaceType.RECENT)
+            this._addRecent(place, type);
+    },
+
     removePlace: function(place, placeType) {
         if (!this.exists(place.osm_id, placeType))
             return;
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index e47430a..6c099f2 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -61,7 +61,8 @@ const SearchResultBubble = new Lang.Class({
                     place = new Place.Place({ place: this.place });
 
                 this._populate(place);
-                Application.placeStore.addRecent(place);
+                Application.placeStore.addPlace(place,
+                                                PlaceStore.PlaceType.RECENT);
             }).bind(this));
         }
         this.content.add(this._stack);


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