jossi87 / climbing-web

React webpage for https://buldreinfo.com and https://brattelinjer.no
https://brattelinjer.no
GNU General Public License v3.0
18 stars 7 forks source link

feat: Introduce state into the filter URL #155

Closed evancharlton closed 4 months ago

evancharlton commented 4 months ago

It's really great that the state of the filter on /problems is saved to the browser-side local storage. However, it can be a bit clunky with the limitation of having just one configuration -- and also with it being private.

Two scenarios which this change aims to address:

  1. Planning for an upcoming trip.
    • When discussing with a group ideas for where we could go climbing tomorrow or this weekend, it can be useful to help others look at the same data you see.
  2. Saving multiple filter configurations.
    • It can be nice to have different filters saved for myself. For example, one might want to have ready access to:
      • I want to go sport climbing tomorrow, anywhere
      • I want to go to Location X tomorrow, any type of climbing
      • Walls that will be shady in the afternoon

This change addresses both of those use cases by taking the current filter, encoding it into a string, and then stuffing it into the hash fragment of the URL.

The user can then take their current URL and send it to their friends:

What do you think about these routes?

Similarly, the user can also bookmark the current URL in their browser's bookmarks feature. Then they can easily hop between different filters.

Future expansions could include moving this to the server-side of things to allow for even better favoriting / sharing / syncing. However, this is a relatively cheap way to test the popularity of the feature before committing to a larger build-out.

evancharlton commented 4 months ago

I'm not 100% sold on the current approach, as implemented here. I wouldn't be opposed to a "soft-launch" of having a share button or permalink button in the filter controls, rather than automagically updating the URL on the fly.

Another thing I'm still mulling over is whether to include some sort of versioning in the filters - if we're making bookmarkable URLs, we should aim to not break them if the filter format changes.

All the same, I'm publishing it for review / testing :)

jossi87 commented 4 months ago

I'll test it out. Not the end of the world if something breaks in the future, but I agree that it's a good idea to try to keep old links alive. Can you resolve the conflict, I'll merge it and test it out after that :)

evancharlton commented 4 months ago

I'll test it out. Not the end of the world if something breaks in the future, but I agree that it's a good idea to try to keep old links alive. Can you resolve the conflict, I'll merge it and test it out after that :)

I'll fix it up tonight and be ready to keep an eye on Sentry - if anything blows up, we can revert :)

jossi87 commented 4 months ago

Sounds good. I see that you committed after the comment. The checks still fail btw, I'll check it again after next commit :)

evancharlton commented 4 months ago

Yeah, I did a quick merge conflict resolution and pushed without building or testing. I'll revisit after the work day :-)

evancharlton commented 4 months ago

Fixed (glad to see #154 catching bugs!)