Skip to content

mergeCollection: discrepancy between cache & storage behaviours #514

@paultsimura

Description

@paultsimura

I've put up a draft PR with a unit test to cover this issue, and a potential fix: #515

Test case:

  1. Setup the initial value:
const initialValue = {
    pendingFields: {
        waypoints: 'add'
    },
};
Onyx.set('transactions_test', initialValue);
  1. Perform the following mergeCollection operation:
Onyx.mergeCollection('transactions_', {
    transactions_test: {
        pendingFields: {
            waypoints: null
        },
    },
});
  1. Verify the collection item subscriber was called with the following value:
{
    "pendingFields": {
        "waypoints": null
    },
}
  1. 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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions