react-native-onyx 2.0.68 → 2.0.69
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/OnyxUtils.d.ts +6 -5
- package/dist/OnyxUtils.js +6 -5
- package/package.json +1 -1
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -75,7 +75,8 @@ declare function isCollectionMemberKey<TCollectionKey extends CollectionKeyBase>
|
|
|
75
75
|
/**
|
|
76
76
|
* Splits a collection member key into the collection key part and the ID part.
|
|
77
77
|
* @param key - The collection member key to split.
|
|
78
|
-
* @returns A tuple where the first element is the collection part and the second element is the ID part
|
|
78
|
+
* @returns A tuple where the first element is the collection part and the second element is the ID part,
|
|
79
|
+
* or throws an Error if the key is not a collection one.
|
|
79
80
|
*/
|
|
80
81
|
declare function splitCollectionMemberKey<TKey extends CollectionKey, CollectionKeyType = TKey extends `${infer Prefix}_${string}` ? `${Prefix}_` : never>(key: TKey): [CollectionKeyType, string];
|
|
81
82
|
/**
|
|
@@ -86,7 +87,7 @@ declare function isKeyMatch(configKey: OnyxKey, key: OnyxKey): boolean;
|
|
|
86
87
|
/** Checks to see if this key has been flagged as safe for removal. */
|
|
87
88
|
declare function isSafeEvictionKey(testKey: OnyxKey): boolean;
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
+
* Extracts the collection identifier of a given collection member key.
|
|
90
91
|
*
|
|
91
92
|
* For example:
|
|
92
93
|
* - `getCollectionKey("report_123")` would return "report_"
|
|
@@ -94,10 +95,10 @@ declare function isSafeEvictionKey(testKey: OnyxKey): boolean;
|
|
|
94
95
|
* - `getCollectionKey("report_-1_something")` would return "report_"
|
|
95
96
|
* - `getCollectionKey("sharedNVP_user_-1_something")` would return "sharedNVP_user_"
|
|
96
97
|
*
|
|
97
|
-
* @param
|
|
98
|
-
* @
|
|
98
|
+
* @param key - The collection key to process.
|
|
99
|
+
* @returns The plain collection key or throws an Error if the key is not a collection one.
|
|
99
100
|
*/
|
|
100
|
-
declare function getCollectionKey(key:
|
|
101
|
+
declare function getCollectionKey(key: CollectionKey): string;
|
|
101
102
|
/**
|
|
102
103
|
* Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
|
|
103
104
|
* If the requested key is a collection, it will return an object with all the collection members.
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -332,7 +332,8 @@ function isCollectionMemberKey(collectionKey, key, collectionKeyLength) {
|
|
|
332
332
|
/**
|
|
333
333
|
* Splits a collection member key into the collection key part and the ID part.
|
|
334
334
|
* @param key - The collection member key to split.
|
|
335
|
-
* @returns A tuple where the first element is the collection part and the second element is the ID part
|
|
335
|
+
* @returns A tuple where the first element is the collection part and the second element is the ID part,
|
|
336
|
+
* or throws an Error if the key is not a collection one.
|
|
336
337
|
*/
|
|
337
338
|
function splitCollectionMemberKey(key) {
|
|
338
339
|
const collectionKey = getCollectionKey(key);
|
|
@@ -350,7 +351,7 @@ function isSafeEvictionKey(testKey) {
|
|
|
350
351
|
return evictionAllowList.some((key) => isKeyMatch(key, testKey));
|
|
351
352
|
}
|
|
352
353
|
/**
|
|
353
|
-
*
|
|
354
|
+
* Extracts the collection identifier of a given collection member key.
|
|
354
355
|
*
|
|
355
356
|
* For example:
|
|
356
357
|
* - `getCollectionKey("report_123")` would return "report_"
|
|
@@ -358,8 +359,8 @@ function isSafeEvictionKey(testKey) {
|
|
|
358
359
|
* - `getCollectionKey("report_-1_something")` would return "report_"
|
|
359
360
|
* - `getCollectionKey("sharedNVP_user_-1_something")` would return "sharedNVP_user_"
|
|
360
361
|
*
|
|
361
|
-
* @param
|
|
362
|
-
* @
|
|
362
|
+
* @param key - The collection key to process.
|
|
363
|
+
* @returns The plain collection key or throws an Error if the key is not a collection one.
|
|
363
364
|
*/
|
|
364
365
|
function getCollectionKey(key) {
|
|
365
366
|
// Start by finding the position of the last underscore in the string
|
|
@@ -1034,7 +1035,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1034
1035
|
// Performance improvement
|
|
1035
1036
|
// If the mapping is connected to an onyx key that is not a collection
|
|
1036
1037
|
// we can skip the call to getAllKeys() and return an array with a single item
|
|
1037
|
-
if (Boolean(mapping.key) && typeof mapping.key === 'string' && !mapping.key
|
|
1038
|
+
if (Boolean(mapping.key) && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && OnyxCache_1.default.getAllKeys().has(mapping.key)) {
|
|
1038
1039
|
return new Set([mapping.key]);
|
|
1039
1040
|
}
|
|
1040
1041
|
return getAllKeys();
|