Can directly display a Post on the same view by a clic on the Marker and to no display any Post just clic anywhere on the GoogleMap
Postview only shows all Post in a radius of 2km (the max the user can)
Back end
Optimization of query on Firebase, if the set of post's keys hasn't changed with a radius change, it will not query a fetch.
File in comment
This file is in comment because if we don't have enough code coverage I will try to fix these tests, as the implementation has changed they are not up to date
What could be improved for a V2
Initially, the update was done dynamically, but it could happen that the nearest posts would remain displayed even if they were outside the circle. Imagine three layers: layer 1 with 0 posts, layer 2 with 1 post, and layer 3 with 2 posts. If the radius is larger than layer 3, the map will display 3 posts. By reducing the radius, we will be smaller than layer 3, so it will query only the posts from layer 2 and layer 1. However, if we reduce the radius quickly enough to have only layer 1 in the circle, since there are no posts, the query response will be faster than that of layer 3 to 2, resulting in the final query response from 3 to 2.
I tried several ways to solve this small problem, such as using locks or CAS (Compare and Swap). None were very convincing, even though some solutions seemed to reduce the probability of encountering this scenario. I felt more like I was doing code tinkering that depended on the speed of Firebase, and the solution wouldn't scale with the number of posts in the second layer.
So currently, the update is no longer done dynamically to avoid this scenario. I find it a bit less nice, but for a V2, it could be cool to make it dynamic again.
Here a small video of the problem in a dynamically fashion
Improvement of the Map
What's new
Front end
Post
on the same view by a clic on theMarker
and to no display anyPost
just clic anywhere on theGoogleMap
Postview
only shows allPost
in a radius of 2km (the max the user can)Back end
File in comment
This file is in comment because if we don't have enough code coverage I will try to fix these tests, as the implementation has changed they are not up to date
What could be improved for a V2
Initially, the update was done dynamically, but it could happen that the nearest posts would remain displayed even if they were outside the circle. Imagine three layers: layer 1 with 0 posts, layer 2 with 1 post, and layer 3 with 2 posts. If the radius is larger than layer 3, the map will display 3 posts. By reducing the radius, we will be smaller than layer 3, so it will query only the posts from layer 2 and layer 1. However, if we reduce the radius quickly enough to have only layer 1 in the circle, since there are no posts, the query response will be faster than that of layer 3 to 2, resulting in the final query response from 3 to 2.
I tried several ways to solve this small problem, such as using locks or CAS (Compare and Swap). None were very convincing, even though some solutions seemed to reduce the probability of encountering this scenario. I felt more like I was doing code tinkering that depended on the speed of Firebase, and the solution wouldn't scale with the number of posts in the second layer.
So currently, the update is no longer done dynamically to avoid this scenario. I find it a bit less nice, but for a V2, it could be cool to make it dynamic again.
Here a small video of the problem in a dynamically fashion