I've put up a draft PR with a unit test to cover this issue, and a potential fix: #515
Test case:
- Setup the initial value:
const initialValue = {
pendingFields: {
waypoints: 'add'
},
};
Onyx.set('transactions_test', initialValue);
- Perform the following
mergeCollection operation:
Onyx.mergeCollection('transactions_', {
transactions_test: {
pendingFields: {
waypoints: null
},
},
});
- Verify the collection item subscriber was called with the following value:
{
"pendingFields": {
"waypoints": null
},
}
-
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:
{
"pendingFields": {
"waypoints": "add"
}
}
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, the pendingFields are fetched from the Storage and show waypoints: "add".
I've put up a draft PR with a unit test to cover this issue, and a potential fix: #515
Test case:
mergeCollectionoperation:{ "pendingFields": { "waypoints": null }, }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:
{ "pendingFields": { "waypoints": "add" } }This causes the following bug: after the operation is complete, the
pendingFieldsare reset correctly (because the subscriber callback is called with the cached data), but after the page is refreshed, thependingFieldsare fetched from the Storage and showwaypoints: "add".