After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741767 - Unify favoritesPopover/placeEntry filter code
Unify favoritesPopover/placeEntry filter code
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2014-12-19 15:53 UTC by Damián Nohales
Modified: 2014-12-22 17:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Unify favoritesPopover/placeEntry filter code (2.98 KB, patch)
2014-12-19 15:53 UTC, Damián Nohales
accepted-commit_now Details | Review
Use Place instead of Geocode.Place (5.91 KB, patch)
2014-12-22 14:04 UTC, Damián Nohales
reviewed Details | Review
Unify favoritesPopover/placeEntry filter code (3.09 KB, patch)
2014-12-22 14:05 UTC, Damián Nohales
reviewed Details | Review
Use Place instead of Geocode.Place (8.12 KB, patch)
2014-12-22 14:56 UTC, Damián Nohales
committed Details | Review
Unify favoritesPopover/placeEntry filter code (3.09 KB, patch)
2014-12-22 14:57 UTC, Damián Nohales
committed Details | Review

Description Damián Nohales 2014-12-19 15:53:01 UTC
Let's move favoritesPopover/placeEntry callback for place filtering to utils, so we can reuse a little bit of code.
Comment 1 Damián Nohales 2014-12-19 15:53:42 UTC
Created attachment 293061 [details] [review]
Unify favoritesPopover/placeEntry filter code
Comment 2 Jonas Danielsson 2014-12-19 16:06:56 UTC
Review of attachment 293061 [details] [review]:

Seems fine for me.

I know Mattias dislikes utils as a dumping ground for all sorts of code :)
But I also suspect he wants to do something about it on a grander scale, so dumping a big more should be fine.
Comment 3 Mattias Bengtsson 2014-12-19 16:31:54 UTC
Review of attachment 293061 [details] [review]:

::: src/utils.js
@@ +386,3 @@
+
+function matchPlace(place, searchString)
+{

The curly brace should be on the same line as the function definition.
Comment 4 Mattias Bengtsson 2014-12-19 16:36:50 UTC
Hm. Yeah I don't like what utils.js has grown into at all.

We don't happen to be so lucky that the only places you want to run this code
on are actually instances of Place (in Place.js)? If so I'd prefer to add a
match-method to that instead.
Comment 5 Damián Nohales 2014-12-19 17:59:10 UTC
(In reply to comment #4)
> We don't happen to be so lucky that the only places you want to run this code
> on are actually instances of Place (in Place.js)? If so I'd prefer to add a
> match-method to that instead.

Yeah, I have the same idea and preference while coding this. But as you say, we have no guarantee to have Place instances everywhere.

Maybe we can start doing something from that point, using Place class everywhere.
Comment 6 Jonas Danielsson 2014-12-19 18:32:22 UTC
Well since the placeStore gives place.js Places, the only place where we do not get them is geocodeService,js, and since you can instanciate a place.js Place from a GeocodePlace it would be quite simple to make sure, right?
Comment 7 Mattias Bengtsson 2014-12-19 21:24:01 UTC
Hm yeah, so either that or just a function in place.js.
Comment 8 Jonas Danielsson 2014-12-19 22:08:18 UTC
Btw, since everything we are comparing here is from the place store we are guarenteed to have place.js places.
Comment 9 Mattias Bengtsson 2014-12-20 14:40:54 UTC
(In reply to comment #8)
> Btw, since everything we are comparing here is from the place store we are
> guarenteed to have place.js places.

Ok so a method on Place then? Does that make sense Damián?
Comment 10 Damián Nohales 2014-12-22 12:34:57 UTC
(In reply to comment #9)
> Ok so a method on Place then? Does that make sense Damián?

Yup, going to submit the patch in a moment.
Comment 11 Damián Nohales 2014-12-22 14:04:59 UTC
Created attachment 293180 [details] [review]
Use Place instead of Geocode.Place

---

This maybe is not necessary to the place filter changes
but I think is better to guarantee that a place object
is always an instance of Place in every part of Maps.
Comment 12 Damián Nohales 2014-12-22 14:05:08 UTC
Created attachment 293181 [details] [review]
Unify favoritesPopover/placeEntry filter code

The code is moved to a method in Place class.
Comment 13 Jonas Danielsson 2014-12-22 14:11:02 UTC
Review of attachment 293181 [details] [review]:

::: src/place.js
@@ +181,3 @@
+
+    match: function(searchString) {
+        let name = this.name;

One thing that is a bit worrysome is that "this.name" is not the same that the user see, right?
Since we use the searchFormatter. But that is the same in the old way we did this as well.

So I guess this is fine, and maybe we can rethink the filtering later to make it more awesome.

@@ +192,3 @@
+
+        if (searchString.length === 0)
+            return true;

Maybe move this to the top of the function, since everything else is useless if this condition is met?

::: src/placeEntry.js
@@ +166,1 @@
+        if (place !== null)

Can place be null here?
Comment 14 Jonas Danielsson 2014-12-22 14:14:09 UTC
Review of attachment 293180 [details] [review]:

Humehum, so I think I am fine with this.

Some thoughts.

* In the places we are switching from Geocode to Place, is the imports line for Geocode still necessary?
* In overpass.js maybe we do not need to create a new place in addInfo? But instead fill in the passed one.
Comment 15 Jonas Danielsson 2014-12-22 14:14:53 UTC
(In reply to comment #13)
> Review of attachment 293181 [details] [review]:
> 
> ::: src/place.js
> @@ +181,3 @@
> +
> +    match: function(searchString) {
> +        let name = this.name;
> 
> One thing that is a bit worrysome is that "this.name" is not the same that the
> user see, right?
> Since we use the searchFormatter. But that is the same in the old way we did
> this as well.
> 
> So I guess this is fine, and maybe we can rethink the filtering later to make
> it more awesome.
> 
> @@ +192,3 @@
> +
> +        if (searchString.length === 0)
> +            return true;
> 
> Maybe move this to the top of the function, since everything else is useless if
> this condition is met?
> 
> ::: src/placeEntry.js
> @@ +166,1 @@
> +        if (place !== null)
> 
> Can place be null here?

s/searchFormatter/placeFormatter/
Comment 16 Jonas Danielsson 2014-12-22 14:21:03 UTC
Review of attachment 293180 [details] [review]:

::: src/geocodeService.js
@@ +55,3 @@
+                    places = places.map(function(p) {
+                        return new Place.Place({ place: p });
+                    });

I would like braces around multiline statements like these, to help readability.

::: src/searchResultBubble.js
@@ +63,3 @@
             overpass.addInfo(this.place, (function(status, code, place) {
                 if (!status)
+                    place = this.place;

If we modify addInfo to only addInfo and not create a new place, then this becomes useless, and we can use this.place throughout, right?
Comment 17 Damián Nohales 2014-12-22 14:42:47 UTC
Review of attachment 293181 [details] [review]:

::: src/place.js
@@ +181,3 @@
+
+    match: function(searchString) {
+        let name = this.name;

I kept the same logic as before, but you are right.

Maybe we should filter the by searching in title and subtitle as is shown in search popup and also make the subtitle bold for the matched part.

@@ +192,3 @@
+
+        if (searchString.length === 0)
+            return true;

Ok, moving it after GLib.utf8_normalize of searchString

::: src/placeEntry.js
@@ +166,1 @@
+        if (place !== null)

Indeed, it happens when I insert or remove an element from the place store. Maybe this from the gtk_tree_model_filter_set_visible_func documentation is related: "Note that func is called whenever a row is inserted, when it may still be empty. The visible function should therefore take special care of empty rows, like in the example below."

Also, we were doing almost the same check in the "if (name === null)" line.
Comment 18 Jonas Danielsson 2014-12-22 14:46:53 UTC
Review of attachment 293181 [details] [review]:

::: src/place.js
@@ +181,3 @@
+
+    match: function(searchString) {
+        let name = this.name;

Yeah, maybe. And ideally we would have a concept of "relevance".

::: src/placeEntry.js
@@ +166,1 @@
+        if (place !== null)

Yeah, you are right.
Comment 19 Jonas Danielsson 2014-12-22 14:48:47 UTC
(In reply to comment #18)
> Review of attachment 293181 [details] [review]:
> 
> ::: src/place.js
> @@ +181,3 @@
> +
> +    match: function(searchString) {
> +        let name = this.name;
> 
> Yeah, maybe. And ideally we would have a concept of "relevance".
> 
> ::: src/placeEntry.js
> @@ +166,1 @@
> +        if (place !== null)
> 
> Yeah, you are right.

But I would accept this for now, and we can re-visit if we have time for 3.16.
Comment 20 Damián Nohales 2014-12-22 14:56:56 UTC
Created attachment 293184 [details] [review]
Use Place instead of Geocode.Place
Comment 21 Damián Nohales 2014-12-22 14:57:02 UTC
Created attachment 293185 [details] [review]
Unify favoritesPopover/placeEntry filter code

The code is moved to a method in Place class.
Comment 22 Jonas Danielsson 2014-12-22 15:12:17 UTC
Review of attachment 293184 [details] [review]:

Thanks!
Comment 23 Jonas Danielsson 2014-12-22 15:14:18 UTC
Review of attachment 293185 [details] [review]:

Yesbox!
Comment 24 Damián Nohales 2014-12-22 17:59:41 UTC
Attachment 293184 [details] pushed as e9b9d00 - Use Place instead of Geocode.Place
Attachment 293185 [details] pushed as 0f881a1 - Unify favoritesPopover/placeEntry filter code