Open paultsimura opened 8 months ago
The issue lies here:
When calling prepareKeyValuePairsForStorage(existingKeyCollection)
, we remove the null
values, which results in the data for multiMerge
being: "pendingFields": {}
However, since the existing data holds a value under pendingFields.waypoints
, the newValue
, which is a result of fastMerge({waypoints: 'add'}, {})
, retains the old value in the Storage:
I've put up a draft PR with a unit test to cover this issue, and a potential fix: https://github.com/Expensify/react-native-onyx/pull/515
Test case:
Setup the initial value:
Perform the following
mergeCollection
operation:Verify the collection item subscriber was called with the following value:
Check the data processed in
IDBKeyVal.multiMerge
.Expected: The data persisted in the Storage must be the same as the cached data.
Actual: Storage persists the following data:
This causes the following bug: after the operation is complete, the
pendingFields
are reset correctly (because the subscriber callback is called with the cached data), but after the page is refreshed, thependingFields
are fetched from the Storage and showwaypoints: "add"
.