digidem / mapeo-desktop

Local-first mapping and monitoring in remote environments
https://mapeo.app
GNU General Public License v3.0
261 stars 33 forks source link

Ej/zustand store #738

Closed lightlii closed 1 year ago

lightlii commented 1 year ago

Contributor checklist:

Description

Adds zustand state store with persistence using our current conf store. Versioning is achieved with a STORE_VERSION constant applied to the store, not sure if this is the best way, open to feedback.

closes https://github.com/digidem/mapeo-desktop/issues/735

lightlii commented 1 year ago

ok looks like versioning might be better handled in the conf store? looking at the migrations section here

lightlii commented 1 year ago

added another commit with some types on the store. Not sure they're any good though, Zustand's typescript docs are a bit vague unfortunately...

lightlii commented 1 year ago

Ok I'm slightly more confident in my typings now but still need someone to look over them

lightlii commented 1 year ago

after a little back and forth with @gmaclennan on slack we've decided to replace conf with electron-store. It uses conf under the hood so is theoretically compatible with current persisted configs. I'll go ahead and use this PR to make that change I think since it's so small

lightlii commented 1 year ago

lastly, since we now have a means of persisting state through zustand I suggest removing the createPersistedState. It would be less confusing to have only a single way of persisting state in the app. There's only a single use of it in the app so its a very minor change and again I can roll it into this PR if you agree @ErikSin ?

I haven't been able to confirm it's fully compatible with existing persisted configs but the only thing we're saving is the active tab so at worst user won't see their last tab once when opening the next update which I'd argue is an acceptable trade-off

ErikSin commented 1 year ago

That sounds good! Thanks @lightlii