Skip to content

Commit 6dd4083

Browse files
committed
Clear pending merge queue in multiSet to prevent applying outdated delta changes
1 parent 9c6fb73 commit 6dd4083

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/Onyx.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ function multiSet(data: OnyxMultiSetInput): Promise<void> {
238238

239239
const updatePromises = keyValuePairsToSet.map(([key, value]) => {
240240
const prevValue = cache.get(key, false);
241+
// When we use multiSet to set a key we want to clear the current delta changes from Onyx.merge that were queued
242+
// before the value was set. If Onyx.merge is currently reading the old value from storage, it will then not apply the changes.
243+
if (OnyxUtils.hasPendingMergeForKey(key)) {
244+
delete OnyxUtils.getMergeQueue()[key];
245+
}
241246

242247
// Update cache and optimistically inform subscribers on the next tick
243248
cache.set(key, value);

0 commit comments

Comments
 (0)