dixhuit / unitcrunch-issue-tracker

Issue tracker for UnitCrunch.
https://www.unitcrunch.com
5 stars 0 forks source link

Switch Localstorage to IndexedDB #41

Closed B-iggy closed 10 months ago

B-iggy commented 10 months ago

Problem

Unitcrunch is currently using LocalStorage as the database format for the unit profiles. The max. 200 profile limitation is quite a big obstacle for hardcore users. It would be great if there would be no limit.

Solution

Checking the LocalStorage I doubt the max. limit of 10MB is even reached with the 200 profiles right now but to make it absolutely future ready, the solution would be to switch to the Indexed DB API: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API Since I did a transition in one of my apps, I can give motivation that it is easier than it looks first.

With that transition to Indexed DB no limit would be needed anymore. This can then open up possibilities that free users can only use X profiles and Patreons unlimited.

Additionally an automated profile import from the BSData can be made: https://github.com/BSData/wh40k-10e Patreons can then select in a dropdown what faction they want to import, e.g. Necrons, and you parse the JSON from BSData and the relevant profiles and import it automatically to Unitcrunch.

Or load up all the faction .cat files in the background and the import/export can be removed all together. Users can always search for the latest profile they want to crunch. Use the indexed DB just for personal profile customizations.

That's my wish for 2024 and I'm sure the biggest Patreon boost you can get :) Happy New Year.

dixhuit commented 10 months ago

Hey, thanks for the suggestions.

I've considered all of these points many times. The reason I've not delivered any of it yet is down to 2 things:

  1. I develop UC in my spare time and there are a million things on the todo list. I've been too busy working on other aspects of the app with the limited time I have available.
  2. I've decided to head in a slightly different direction to solve the same problem that you've raised...

IndexedDB is great and it would absolutely solve the issue that you've raised. There are other issues related to using any kind of client-side storage that I'd also like to address though. Primarily: when UC updates from one version to the next, migrating stored data is currently a massive pain in the arse because each user may be migrating from a different version of UC.

My solution to both the issue of migrating stored data and overcoming the limitations of LocalStorage specifically is to move stored data to a remote server (and only use client-side storage for more typical applications: UI state etc). This would require authentication so we'd need to introduce the concept of user accounts. Interestingly, you've also touched on the need for this when you mention "free users" and "Patreon users" getting a different experience - this would also require user accounts and auth in order to know who gets what. Server-stored data and authenticated user accounts would also bring new opportunities that have not been previously possible.

As to what the practical differences would be between "free users" and "Patreon users": this is all to be determined. My current thinking is that Patreon users would benefit from the following:

  1. Increased limits (or possibly no limits) on things like the number of profiles that can be stored.
  2. Cross device syncing of saved data. E.g. Login on your phone and your desktop and your changes will stay in sync.
  3. Support for permalinks: Set up a specific "Crunch" (simulation) and UC will provide a permalink that you can share online. Any user visiting the permalink will see the Crunch as you've set it up. No more sharing screenshots of UC config/results. Maybe free users would still get this, I need to give it more thought.

As for importing profile data from other applications, this is a whole topic on its own. I'd rather not confuse this specific issue with multiple major topics. I will say this though:

B-iggy commented 10 months ago

Good Morning, thanks for your detailed response. I see your issues and like NewRecruit I also think it would be great to bring in a remote server and what I said, that you then can add Patreon only features.

From my experience I would suggest giving Patreons everything that is convenient and saves their time. So increased limits make sense, as well as permalinks and a better Import of profiles. Syncing data is a core element I would make available to everyone. My 2 cents.

and I have concerns about the future of BattleScribe as a project

It started with BattleScribe and it has bad reputation but the BSData team is not working for that alone. New Recruit for example is also making use of it. The only future-issue I see is GW itself, stopping this project one day? Who knows.

Lastly, about your limited time: sure, no problem. I don't have a roadmap of unitcrunch nor do I know how hard you work on UR. So I just wanted to suggest something I didn't see on github yet. Since the remote server data storage is even better than the indexed DB solution I see my suggestion as obsolete and will just wait for this great feature for UR. Your app is the best Mathhammer app out there and helps a lot for making decisions what unit to buy and how to play it. Thanks.

dixhuit commented 10 months ago

Closing as wontfix given the plan I've outlined above (implement auth, back-end & database instead of IndexedDB or any other client-side storage).