Closed ajones05 closed 7 years ago
@abdulhafeez I think we can assign IDs to categories
id | title |
---|---|
1 | Food |
2 | Safety |
3 | Events |
4 | Development |
5 | Other |
And add field category_id to api gateways
mobile/addimobinews mobile/myposts mobile/request-nearest
Are you agree?
@abdulhafeez does this work?
Yes, absolutely. That will be perfect.
OK, I am almost done with UI. Once complete, I'll hookup with APIs and report here in case of issues.
@ajones05 What should be the default category? In case no category_id is present (for example in old posts).
For now we can add "Other" to all, but I will work with @yuriyua so I can update the categories of old posts.
I have done it. The APIs seem to be working fine.
@yuriyua I think @abdulhafeez will need your help for ability to toggle filters on/off. For example, here is how it would look if the Safety category is off (only posts that are "on" should be visible. Posts in categories that are toggled off should not be visible).
I think it can be done on front end only. So, @yuriyua may not be required to do anything. One question: How would you cancel the filter? May be on hiding the filter panel?
ok, let me know if I can any help you. I added category id filter to mobile/myposts api.
How would you cancel the filter?
So nothing else should be needed to cancel the category filter.
Done. Looks to be working great. I am filtering on front end only i.e. only hiding and showing markers.
Great, thanks! I think front end only will not be enough, though. If I am understanding correctly, the front end only approach means that, for example: if all posts are in two categories and they are filtered out, then nothing will appear (on the map, at least), right?
I think this implementation is good, which will let the user see quickly how it's working. However, additionally, when the user hits "Filter" again to close the category options, the posts are refreshed from only the relevant categories. That will require help from @yuriyua but he will be doing the same for the desktop version, anyway.
Done. I updated category filter to multiple values: https://github.com/ajones05/seearound.me/wiki/Mobile-Api-Reference/_compare/154a656a5c4bbb121d527623f0f3ba33a64c3be3...adcd9c9d4aac8eb70e930e4e13de5e68fe4cdfd9
@abdulhafeez you should send category id parameter name in multiple format:
...
&category_id[]=1
&category_id[]=3
&category_id[]=5
...
@ajones05 By "when posts are refreshed" do you mean when the user dismisses filter panel after filtering out and then goes to some other screen and later comes back to map?
If that is the case, we may need to add the filter (category_id[]=1 etc) to mobile/request-nearest api too.
BTW, I still think it can be done without any change on server side.
By "when posts are refreshed" do you mean when the user dismisses filter panel after filtering out and then goes to some other screen and later comes back to map?
No, I mean just when the user dismisses the filter panel. If changes have been made to the current categories, then the posts are refreshed with only posts from those categories, and this change would appear immediately on the map after the filter panel is dismissed (it would also remain in effect if user switches to list view).
Thanks! I think I can maintain a list of filters locally and filter out posts on any view. With this approach we can filter all posts from whichever API call they are coming. I don't see any advantage in doing it on server side. The disadvantage is that it becomes complex to manage filtered responses from different APIs. Or am I mistaken @yuriyua ?
@ajones05 It seems what I have already done is quicker than you expect. It hides the pins as soon as you touch a category. So, I am making an ios build before going further so you can see how it works and also other fixed issues.
OK sounds good. I thought it would only apply to the currently loaded posts (which would mean after filtering some categories out, the map could end up with only a few or even no pins on it if certain categories had few or no posts from those currently loaded), but from what you describe that sounds perfect. Either way it's probably best to see the current build so we are on the same page. Thanks!
I will do it from the server side. Should I save other search parameters?
I think it requires back-end implementation, because if I have filtered out certain categories and am scrolling through List View, for example, then only new posts from categories toggled on should be visible and continue to be loaded at the bottom.
Same for Map View: if I toggle off a category, like Food, then when I dismiss the Filter it should refresh map posts with just the other categories.
But I can filter out those posts locally for all views (which I have not yet done) ... this would be much faster than waiting for responses from server side.
I think it does no make sense to store this parameters from the server side. We can re-send category filter from cookies (or other way from the app).
But I can filter out those posts locally for all views (which I have not yet done) ... this would be much faster than waiting for responses from server side.
I see, OK I thought you had done what was possible already. So basically you would just load more posts initially and filter them out locally? That is what I thought you meant initially.
Exactly and this means @yuriyua does not have to do anything. Just let the server side remain as it was before. This way, yuriyua will not have to apply filters for request-nearest api nor for myposts.
Agreed, OK
@yuriyua can you reverse the change you made to myposts api for multiple filters?
@abdulhafeez Back category ID to single value?
Yes, exactly ... if it does not effect anything.
@ajones05 How should we make category filter on the site (multiple or single)?
You can keep it for site if sending no category_id parameter does not effect things. I will not send any param.
ok, I will back category id parameter to single value for api
Thanks! All is fine now. However, I some times get 500 on request-nearest. Please make sure it stays same as it was before.
I will check logs, please let me know when it will happen again.
I think this implementation is good, which will let the user see quickly how it's working. However, additionally, when the user hits "Filter" again to close the category options, the posts are refreshed from only the relevant categories.
It works well to immediately show the filter changes. However, after I dismiss the filter panel, it still does not update the top 15 with just the active categories.
Are you talking about list view? The view should stay same after dismissing the categories popover.
No, I mean in map view. This is why: if most or all posts are in one or a few categories (like in this screenshot, where most are "food") then the user is simply looking at a blank map.
Sorry, I am still failing to understand this requirement. When the popover is dismissed, the map shows only the pins from selected categories. It is already that way. Why do you want to refresh the same view? It will result in the same view in same state. OR do you mean we should cancel all filters and show all pins when dismissed?
No problem, let me try to explain better. When the filter is dismissed, the user should again see the top 15 posts. However, now it is the top 15 with the filter applied. So in the screenshot above, after the filter is dismissed, it should show the top 15 posts in Safety, Events, Development, and Other -- but not Food. (Right now, it just shows an empty map, because all 15 top posts in this area right now are Food).
OK, that (the scene in the screen shot) is possibly after moving the circle to a different location?
Whether I move the screen or not, it does not show 15 map pins. It only shows (15 - (whatever is filtered off)). So for example it will show 0 or 3 or 6 or 11, but not 15 unless the filters that are off were not visible in the original 15 anyway
OK, I think I finally understood what you mean and unfortunately, we are back to the start ... this cannot be done on front end only. It involves back end. @yuriyua have you understood this requirement?
OK that's what I had thought. @yuriyua let me know if you need anything, but basically we need the API to do the same as on desktop.
DONE. I changed category filter query to order.
@yuriyua can you please guide me what params I need to send to get next top 15 filtered posts? on request-nearest api.
Based on feedback, I finally decided to add five categories for posts. Here are the changes that will be involved. Let me know what you think and if you have any questions. I'll work with @yuriyua to make APIs. https://www.dropbox.com/sh/4n44h6h9nz6hv2u/AAAr3ljEIalWuFaMtb_F7twRa?dl=0