react-native-onyx 2.0.97 → 2.0.99
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 +6 -6
- package/dist/useOnyx.js +3 -2
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -543,7 +543,7 @@ function clear(keysToPreserve = []) {
|
|
|
543
543
|
function updateSnapshots(data) {
|
|
544
544
|
const snapshotCollectionKey = OnyxUtils_1.default.getSnapshotKey();
|
|
545
545
|
if (!snapshotCollectionKey)
|
|
546
|
-
return;
|
|
546
|
+
return [];
|
|
547
547
|
const promises = [];
|
|
548
548
|
const snapshotCollection = OnyxUtils_1.default.getCachedCollection(snapshotCollectionKey);
|
|
549
549
|
const snapshotCollectionKeyLength = snapshotCollectionKey.length;
|
|
@@ -583,7 +583,7 @@ function updateSnapshots(data) {
|
|
|
583
583
|
}
|
|
584
584
|
promises.push(() => merge(snapshotKey, { data: updatedData }));
|
|
585
585
|
});
|
|
586
|
-
return
|
|
586
|
+
return promises;
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Insert API responses and lifecycle data into Onyx
|
|
@@ -699,10 +699,10 @@ function update(data) {
|
|
|
699
699
|
promises.push(() => merge(key, batchedChanges));
|
|
700
700
|
}
|
|
701
701
|
});
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
702
|
+
const snapshotPromises = updateSnapshots(data);
|
|
703
|
+
// We need to run the snapshot updates before the other updates so the snapshot data can be updated before the loading state in the snapshot
|
|
704
|
+
const finalPromises = snapshotPromises.concat(promises);
|
|
705
|
+
return clearPromise.then(() => Promise.all(finalPromises.map((p) => p()))).then(() => undefined);
|
|
706
706
|
}
|
|
707
707
|
/**
|
|
708
708
|
* Sets a collection by replacing all existing collection members with new values.
|
package/dist/useOnyx.js
CHANGED
|
@@ -193,8 +193,9 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
193
193
|
const newStatus = newFetchStatus !== null && newFetchStatus !== void 0 ? newFetchStatus : 'loaded';
|
|
194
194
|
resultRef.current = [(_c = previousValueRef.current) !== null && _c !== void 0 ? _c : undefined, { status: newStatus }];
|
|
195
195
|
// If `canBeMissing` is set to `false` and the Onyx value of that key is not defined,
|
|
196
|
-
// we log an alert so it can be acknowledged by the consumer.
|
|
197
|
-
if
|
|
196
|
+
// we log an alert so it can be acknowledged by the consumer. Additionally, we won't log alerts
|
|
197
|
+
// if there's a `Onyx.clear()` task in progress.
|
|
198
|
+
if ((options === null || options === void 0 ? void 0 : options.canBeMissing) === false && newStatus === 'loaded' && !isOnyxValueDefined && !OnyxCache_1.default.hasPendingTask(OnyxCache_1.TASK.CLEAR)) {
|
|
198
199
|
Logger.logAlert(`useOnyx returned no data for key with canBeMissing set to false.`, { key, showAlert: true });
|
|
199
200
|
}
|
|
200
201
|
}
|