[gnome-maps] Add 'store' property on Place



commit 5ab82f188f5aef87dcfa4e887cc69e1b38544e86
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Oct 26 14:24:51 2015 +0100

    Add 'store' property on Place
    
    This property determines if the place should be stored
    in the placeStore or not. Will replace checking the instance of
    the place to determine this.

 src/contactPlace.js |    1 +
 src/place.js        |   16 ++++++++++++++++
 src/placeBubble.js  |    8 ++++----
 src/placeStore.js   |    6 +++---
 4 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/contactPlace.js b/src/contactPlace.js
index 1ff29d4..1a587c9 100644
--- a/src/contactPlace.js
+++ b/src/contactPlace.js
@@ -31,6 +31,7 @@ const ContactPlace = new Lang.Class({
         this._contact = params.contact;
         delete params.contact;
 
+        params.store = false;
         this.parent(params);
     },
 
diff --git a/src/place.js b/src/place.js
index c125b44..75be62a 100644
--- a/src/place.js
+++ b/src/place.js
@@ -39,6 +39,14 @@ const Place = new Lang.Class({
         this._openingHours = params.openingHours;
         delete params.openingHours;
 
+        /* Determines if the place should be added to the place store */
+        if (typeof(params.store) === 'undefined') {
+            this._store = true;
+        } else {
+            this._store = params.store;
+            delete params.store;
+        }
+
         this._wheelchair = params.wheelchair;
         delete params.wheelchair;
 
@@ -69,6 +77,14 @@ const Place = new Lang.Class({
         this.parent(params);
     },
 
+    set store(v) {
+        this._store = v;
+    },
+
+    get store() {
+        return this._store;
+    },
+
     get uniqueID() {
         return this.osm_type + '-' + this.osm_id;
     },
diff --git a/src/placeBubble.js b/src/placeBubble.js
index 98bcce4..4759b68 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -43,9 +43,7 @@ const PlaceBubble = new Lang.Class({
         params.buttons = (MapBubble.Button.ROUTE |
                           MapBubble.Button.SEND_TO);
 
-        // We do not serialize contacts to file, so adding them
-        // as favourites does not makes sense right now.
-        if (!(params.place instanceof ContactPlace.ContactPlace))
+        if (params.place.store)
             params.buttons |= MapBubble.Button.FAVORITE;
 
         this.parent(params);
@@ -71,12 +69,14 @@ const PlaceBubble = new Lang.Class({
                 let place = Application.placeStore.get(this.place);
                 this._populate(place);
             }
-        } else {
+        } else if (this.place.store) {
             overpass.addInfo(this.place, (function(status, code) {
                 this._populate(this.place);
                 Application.placeStore.addPlace(this.place,
                                                 PlaceStore.PlaceType.RECENT);
             }).bind(this));
+        } else {
+            this._populate(this.place);
         }
         this.content.add(this._stack);
     },
diff --git a/src/placeStore.js b/src/placeStore.js
index 53dcbec..2536ed8 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -88,7 +88,7 @@ const PlaceStore = new Lang.Class({
     },
 
     _addFavorite: function(place) {
-        if (place instanceof ContactPlace.ContactPlace)
+        if (!place.store)
             return;
 
         if (this.exists(place, PlaceType.FAVORITE)) {
@@ -105,7 +105,7 @@ const PlaceStore = new Lang.Class({
     },
 
     _addRecent: function(place) {
-        if (place instanceof ContactPlace.ContactPlace)
+        if (!place.store)
             return;
 
         if (this.exists(place, PlaceType.RECENT)) {
@@ -234,7 +234,7 @@ const PlaceStore = new Lang.Class({
             let type = model.get_value(iter, Columns.TYPE);
             let added = model.get_value(iter, Columns.ADDED);
 
-            if (!place || place instanceof ContactPlace.ContactPlace)
+            if (!place || !place.store)
                 return;
 
             jsonArray.push({


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