Gobluebro / Elden-Ring-Checklist

A checklist for you to complete as you go through Elden Ring.
https://gobluebro.github.io/Elden-Ring-Checklist/
MIT License
72 stars 25 forks source link

Add hash values to maintain tab between page loads #54

Closed shobensack closed 5 months ago

shobensack commented 5 months ago

Hey @Gobluebro, I thought it would be neat to set hash values in the url to land you on the correct tab each time you hit the site, rather than always defaulting to "Quests." The default remains "Quests" if no hash value is present, or the hash value is a bad value. Seems useful so you don't have to constantly switch tabs anytime you come back to the page (an issue I have frequently with an otherwise great web app!) Thanks!

Gobluebro commented 5 months ago

Thanks for your interest in the project.

I'd going to make some changes before pulling.

In the meantime, I do have a question. Are you saving the whole url when you are coming back to this page? I guess I'm confused on how you'd come back to it with the tab already in the URL. Maybe we should be storing the current tab in local storage so anytime you comeback to the page you can resume where you left off even if you don't have the url hash included.

Gobluebro commented 5 months ago

Another question, do we need to keep a history of what tabs you have been on? Currently this code will continue to update your browser history every time you click a new tab. I don't know what the benefit of that would be. I'm going to change it so the history doesn't update every time.

shobensack commented 5 months ago

@Gobluebro So the use case is that I use the checklist on my phone, and switch between the checklist and the Elden Ring wiki a lot. When navigating back to the checklist browser tab in Chrome, sometimes the page reloads which drops you back off at the "Quest" checklist tab (iOS + Chrome, though I'm sure most mobile browsers do this, I think its a memory saving thing).

Yeah, that is a good point, I don't think its neccessary to store browser history entries at all, and makes much more sense to just store in local storage for anytime you come back to the checklist.

I just added a commit that uses local storage, instead of hash values.

Gobluebro commented 5 months ago

So when you switch back and forth from mobile to desktop, does your checklist state sync? It saves all of your progress through local storage, but I assumed that was localized per device.

If it is the case that chrome is syncing both phone and desktop local storage then this solution should work well

shobensack commented 5 months ago

@Gobluebro Sorry, when I said iOS + Chrome, I meant I use it mobile only using Chrome on iOS.

Local storage is per device, as far as I know.

Gobluebro commented 5 months ago

Ah okay thanks you for clarifying

Gobluebro commented 5 months ago

I have a hook that does this local storage work for me. I replaced the default enum value and made quests the default value in the hook.

shobensack commented 5 months ago

@Gobluebro woohoo! Thanks for the awesome checklist!

Gobluebro commented 5 months ago

Thank you for the kind words and for helping make this website better