Open mtfurlan opened 2 years ago
Thanks for pointing this out. Definitely an oversight on my part. Reloading the selections before writing the updated selections definitely sounds like a good idea. I'm considering moving some of the stored data from LocalStorage to IndexedDB. Not sure whether the selections would be part of this, though.
If a user has multiple tabs open (such as a bunch of presenters from the people list), and changes selected items in each tab, only the selections done in the last tab will be saved.
It looks like this happens because each tab loads the selections at page load, and the blindly writes what it loaded plus what the user selected: https://github.com/lostcarpark/conclar/blob/main/src/model.js#L159
I think reading the local storage every time a user changes a selection instead of assuming what it read on page load is correct would solve the problem.
There technically could still be race condition stuff if two tabs do stuff at the exact same time, I don't think that would happen in a real world usecase because local storage is measured in ms, so a user would have to be doing stuff on two tabs at the exact same time.