react-native-onyx 3.0.22 → 3.0.23
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/dist/OnyxUtils.d.ts +7 -0
- package/dist/OnyxUtils.js +17 -0
- package/package.json +1 -1
package/dist/Onyx.js
CHANGED
|
@@ -60,7 +60,11 @@ function init({ keys = {}, initialKeyStates = {}, evictableKeys = [], maxCachedK
|
|
|
60
60
|
if (shouldSyncMultipleInstances) {
|
|
61
61
|
(_a = storage_1.default.keepInstancesSync) === null || _a === void 0 ? void 0 : _a.call(storage_1.default, (key, value) => {
|
|
62
62
|
OnyxCache_1.default.set(key, value);
|
|
63
|
-
|
|
63
|
+
// Check if this is a collection member key to prevent duplicate callbacks
|
|
64
|
+
// When a collection is updated, individual members sync separately to other tabs
|
|
65
|
+
// Setting isProcessingCollectionUpdate=true prevents triggering collection callbacks for each individual update
|
|
66
|
+
const isKeyCollectionMember = OnyxUtils_1.default.isCollectionMember(key);
|
|
67
|
+
OnyxUtils_1.default.keyChanged(key, value, undefined, true, isKeyCollectionMember);
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
70
|
if (maxCachedKeysCount > 0) {
|
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -107,6 +107,12 @@ declare function getCollectionKeys(): Set<OnyxKey>;
|
|
|
107
107
|
*/
|
|
108
108
|
declare function isCollectionKey(key: OnyxKey): key is CollectionKeyBase;
|
|
109
109
|
declare function isCollectionMemberKey<TCollectionKey extends CollectionKeyBase>(collectionKey: TCollectionKey, key: string): key is `${TCollectionKey}${string}`;
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a given key is a collection member key (not just a collection key).
|
|
112
|
+
* @param key - The key to check
|
|
113
|
+
* @returns true if the key is a collection member, false otherwise
|
|
114
|
+
*/
|
|
115
|
+
declare function isCollectionMember(key: OnyxKey): boolean;
|
|
110
116
|
/**
|
|
111
117
|
* Splits a collection member key into the collection key part and the ID part.
|
|
112
118
|
* @param key - The collection member key to split.
|
|
@@ -328,6 +334,7 @@ declare const OnyxUtils: {
|
|
|
328
334
|
getCollectionKeys: typeof getCollectionKeys;
|
|
329
335
|
isCollectionKey: typeof isCollectionKey;
|
|
330
336
|
isCollectionMemberKey: typeof isCollectionMemberKey;
|
|
337
|
+
isCollectionMember: typeof isCollectionMember;
|
|
331
338
|
splitCollectionMemberKey: typeof splitCollectionMemberKey;
|
|
332
339
|
isKeyMatch: typeof isKeyMatch;
|
|
333
340
|
tryGetCachedValue: typeof tryGetCachedValue;
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -391,6 +391,22 @@ function isCollectionKey(key) {
|
|
|
391
391
|
function isCollectionMemberKey(collectionKey, key) {
|
|
392
392
|
return key.startsWith(collectionKey) && key.length > collectionKey.length;
|
|
393
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Checks if a given key is a collection member key (not just a collection key).
|
|
396
|
+
* @param key - The key to check
|
|
397
|
+
* @returns true if the key is a collection member, false otherwise
|
|
398
|
+
*/
|
|
399
|
+
function isCollectionMember(key) {
|
|
400
|
+
try {
|
|
401
|
+
const collectionKey = getCollectionKey(key);
|
|
402
|
+
// If the key is longer than the collection key, it's a collection member
|
|
403
|
+
return key.length > collectionKey.length;
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
// If getCollectionKey throws, the key is not a collection member
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
394
410
|
/**
|
|
395
411
|
* Splits a collection member key into the collection key part and the ID part.
|
|
396
412
|
* @param key - The collection member key to split.
|
|
@@ -1393,6 +1409,7 @@ const OnyxUtils = {
|
|
|
1393
1409
|
getCollectionKeys,
|
|
1394
1410
|
isCollectionKey,
|
|
1395
1411
|
isCollectionMemberKey,
|
|
1412
|
+
isCollectionMember,
|
|
1396
1413
|
splitCollectionMemberKey,
|
|
1397
1414
|
isKeyMatch,
|
|
1398
1415
|
tryGetCachedValue,
|