ingoclaro / kdm-companion

Other
1 stars 1 forks source link

settlements list should be a map instead of array #23

Open ingoclaro opened 5 years ago

ingoclaro commented 5 years ago

this is for the multiplayer part. Pubsub uses a ref, when it's referencing an array it looks like this: /campaigns/1

The issue is that this can be invalid if we delete campaings/0, then the pubsub is going to reference an invalid campaign, which would corrupt data, or a non existing campaign, which would probably crash the app.

To fix this, if we make the campaigns a map, then it would reference it by id.

ingoclaro commented 5 years ago

another approach, which would involve far less changes is to change how the pubsub reference works. Maybe instead of saving that in the store, always attach a new one, thus doing that reference dynamic every time. Since you need to change to the settlement you want to delete, when switching to the settlement would be a good place to (re)attach the pubsub store. Also do something similar when loading the whole store (with selectedSettlement).