Skip to content

Commit 299ea2d

Browse files
authored
Merge pull request #593 from huult/fix-snapshot-condition-assign
fix update snapshot assignment to merge existing values instead of ov…
2 parents b58dbc5 + de00a22 commit 299ea2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Onyx.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ function updateSnapshots(data: OnyxUpdate[]) {
556556
return;
557557
}
558558

559-
let updatedData = {};
559+
let updatedData: Record<string, unknown> = {};
560560

561561
data.forEach(({key, value}) => {
562562
// snapshots are normal keys so we want to skip update if they are written to Onyx
@@ -573,7 +573,10 @@ function updateSnapshots(data: OnyxUpdate[]) {
573573
return;
574574
}
575575

576-
updatedData = {...updatedData, [key]: lodashPick(value, Object.keys(snapshotData[key]))};
576+
const oldValue = updatedData[key] || {};
577+
const newValue = lodashPick(value, Object.keys(snapshotData[key]));
578+
579+
updatedData = {...updatedData, [key]: Object.assign(oldValue, newValue)};
577580
});
578581

579582
// Skip the update if there's no data to be merged

0 commit comments

Comments
 (0)