react-native-onyx 2.0.37 → 2.0.38

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.
Files changed (2) hide show
  1. package/dist/OnyxUtils.js +12 -9
  2. package/package.json +1 -1
package/dist/OnyxUtils.js CHANGED
@@ -324,16 +324,19 @@ function addAllSafeEvictionKeysToRecentlyAccessedList() {
324
324
  });
325
325
  }
326
326
  function getCachedCollection(collectionKey, collectionMemberKeys) {
327
- const resolvedCollectionMemberKeys = collectionMemberKeys || Array.from(OnyxCache_1.default.getAllKeys()).filter((storedKey) => isCollectionMemberKey(collectionKey, storedKey));
328
- return resolvedCollectionMemberKeys.reduce((prev, key) => {
329
- const cachedValue = OnyxCache_1.default.getValue(key);
330
- if (!cachedValue) {
331
- return prev;
327
+ const allKeys = collectionMemberKeys || OnyxCache_1.default.getAllKeys();
328
+ const collection = {};
329
+ // forEach exists on both Set and Array
330
+ allKeys.forEach((key) => {
331
+ // If we don't have collectionMemberKeys array then we have to check whether a key is a collection member key.
332
+ // Because in that case the keys will be coming from `cache.getAllKeys()` and we need to filter out the keys that
333
+ // are not part of the collection.
334
+ if (!collectionMemberKeys && !isCollectionMemberKey(collectionKey, key)) {
335
+ return;
332
336
  }
333
- // eslint-disable-next-line no-param-reassign
334
- prev[key] = cachedValue;
335
- return prev;
336
- }, {});
337
+ collection[key] = OnyxCache_1.default.getValue(key);
338
+ });
339
+ return collection;
337
340
  }
338
341
  /**
339
342
  * When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.37",
3
+ "version": "2.0.38",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",