Munchable keeps the health part of its state on the device, so a returning user's profile and scan history come off local storage rather than out of a database. Which means the app reads data written by a build of itself that no longer exists, and has to decide what to do with the parts it no longer recognises.
Six stores in the app, and only two of them survive a relaunch: the dietary profile and the history. Both of them override zustand's merge , and both of them throw data away.
The profile drops ids this build does not know
The profile holds three arrays of ids: the conditions you are eating for, the allergies you asked to be warned about, and the things you would rather not buy. All three are re-validated on the way in:
merge : ( persisted , current ) => { const p = ( persisted ?? { } ) as Partial < ProfileState > ; return { . . . current , . . . p , conditions : Array . isArray ( p . conditions ) ? p . conditions . filter ( isConditionId ) : [ ] , allergens : Array . isArray ( p . allergens ) ?…