react-native-onyx 3.0.97 → 3.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Onyx.js +5 -1
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -240,11 +240,15 @@ function merge(key, changes) {
|
|
|
240
240
|
return mergeQueuePromise[key];
|
|
241
241
|
}
|
|
242
242
|
mergeQueue[key] = [changes];
|
|
243
|
-
mergeQueuePromise[key] = OnyxUtils_1.default.get(key).then((
|
|
243
|
+
mergeQueuePromise[key] = OnyxUtils_1.default.get(key).then((valueFromGet) => {
|
|
244
244
|
// Calls to Onyx.set after a merge will terminate the current merge process and clear the merge queue
|
|
245
245
|
if (mergeQueue[key] == null) {
|
|
246
246
|
return Promise.resolve();
|
|
247
247
|
}
|
|
248
|
+
// Other writers (notably Onyx.update's mergeCollection path, which doesn't participate in mergeQueue)
|
|
249
|
+
// can land between get() resolving and this callback running. Applying the delta on top of the value
|
|
250
|
+
// captured back then and broadcasting it would overwrite those writes wholesale, so re-read the cache.
|
|
251
|
+
const existingValue = OnyxCache_1.default.hasCacheForKey(key) ? OnyxCache_1.default.get(key) : valueFromGet;
|
|
248
252
|
try {
|
|
249
253
|
const validChanges = mergeQueue[key].filter((change) => {
|
|
250
254
|
const { isCompatible, existingValueType, newValueType, isEmptyArrayCoercion } = utils_1.default.checkCompatibilityWithExistingValue(change, existingValue);
|