react-native-onyx 3.0.52 → 3.0.54
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/DevTools/RealDevTools.js +2 -2
- package/dist/Onyx.js +11 -10
- package/dist/OnyxCache.d.ts +0 -26
- package/dist/OnyxCache.js +15 -85
- package/dist/OnyxConnectionManager.js +2 -1
- package/dist/OnyxKeys.d.ts +93 -0
- package/dist/OnyxKeys.js +204 -0
- package/dist/OnyxMerge/index.js +2 -1
- package/dist/OnyxMerge/index.native.js +2 -1
- package/dist/OnyxSnapshotCache.js +2 -2
- package/dist/OnyxUtils.d.ts +1 -69
- package/dist/OnyxUtils.js +38 -155
- package/dist/useOnyx.js +2 -1
- package/package.json +1 -1
package/dist/OnyxMerge/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const OnyxCache_1 = __importDefault(require("../OnyxCache"));
|
|
7
|
+
const OnyxKeys_1 = __importDefault(require("../OnyxKeys"));
|
|
7
8
|
const OnyxUtils_1 = __importDefault(require("../OnyxUtils"));
|
|
8
9
|
const storage_1 = __importDefault(require("../storage"));
|
|
9
10
|
const applyMerge = (key, existingValue, validChanges) => {
|
|
@@ -14,7 +15,7 @@ const applyMerge = (key, existingValue, validChanges) => {
|
|
|
14
15
|
OnyxUtils_1.default.logKeyChanged(OnyxUtils_1.default.METHOD.MERGE, key, mergedValue, hasChanged);
|
|
15
16
|
// This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
|
|
16
17
|
const updatePromise = OnyxUtils_1.default.broadcastUpdate(key, mergedValue, hasChanged);
|
|
17
|
-
const shouldSkipStorageOperations = !hasChanged ||
|
|
18
|
+
const shouldSkipStorageOperations = !hasChanged || OnyxKeys_1.default.isRamOnlyKey(key);
|
|
18
19
|
// If the value has not changed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
|
|
19
20
|
// If the key is marked as RAM-only, it should not be saved nor updated in the storage.
|
|
20
21
|
if (shouldSkipStorageOperations) {
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const OnyxKeys_1 = __importDefault(require("../OnyxKeys"));
|
|
6
7
|
const OnyxUtils_1 = __importDefault(require("../OnyxUtils"));
|
|
7
8
|
const OnyxCache_1 = __importDefault(require("../OnyxCache"));
|
|
8
9
|
const storage_1 = __importDefault(require("../storage"));
|
|
@@ -20,7 +21,7 @@ const applyMerge = (key, existingValue, validChanges) => {
|
|
|
20
21
|
OnyxUtils_1.default.logKeyChanged(OnyxUtils_1.default.METHOD.MERGE, key, mergedValue, hasChanged);
|
|
21
22
|
// This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
|
|
22
23
|
const updatePromise = OnyxUtils_1.default.broadcastUpdate(key, mergedValue, hasChanged);
|
|
23
|
-
const shouldSkipStorageOperations = !hasChanged ||
|
|
24
|
+
const shouldSkipStorageOperations = !hasChanged || OnyxKeys_1.default.isRamOnlyKey(key);
|
|
24
25
|
// If the value has not changed, calling Storage.setItem() would be redundant and a waste of performance, so return early instead.
|
|
25
26
|
// If the key is marked as RAM-only, it should not be saved nor updated in the storage.
|
|
26
27
|
if (shouldSkipStorageOperations) {
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OnyxSnapshotCache = void 0;
|
|
7
|
-
const
|
|
7
|
+
const OnyxKeys_1 = __importDefault(require("./OnyxKeys"));
|
|
8
8
|
/**
|
|
9
9
|
* Manages snapshot caching for useOnyx hook performance optimization.
|
|
10
10
|
* Handles selector function tracking and memoized getSnapshot results.
|
|
@@ -99,7 +99,7 @@ class OnyxSnapshotCache {
|
|
|
99
99
|
// Always invalidate the exact key
|
|
100
100
|
this.snapshotCache.delete(keyToInvalidate);
|
|
101
101
|
// Check if the key is a collection member and invalidate the collection base key
|
|
102
|
-
const collectionBaseKey =
|
|
102
|
+
const collectionBaseKey = OnyxKeys_1.default.getCollectionKey(keyToInvalidate);
|
|
103
103
|
if (collectionBaseKey) {
|
|
104
104
|
this.snapshotCache.delete(collectionBaseKey);
|
|
105
105
|
}
|
package/dist/OnyxUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValueOf } from 'type-fest';
|
|
2
2
|
import type Onyx from './Onyx';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionKeyBase, ConnectOptions, DeepRecord, KeyValueMapping, CallbackToStateMapping, MultiMergeReplaceNullPatches, OnyxCollection, OnyxEntry, OnyxInput, OnyxKey, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, Selector, MergeCollectionWithPatchesParams, SetCollectionParams, SetParams, OnyxMultiSetInput, RetriableOnyxOperation } from './types';
|
|
4
4
|
import type { FastMergeResult } from './utils';
|
|
5
5
|
import type { DeferredTask } from './createDeferredTask';
|
|
6
6
|
import type { StorageKeyValuePair } from './storage/providers/types';
|
|
@@ -106,66 +106,6 @@ declare function storeKeyBySubscriptions(key: OnyxKey, subscriptionID: number):
|
|
|
106
106
|
declare function deleteKeyBySubscriptions(subscriptionID: number): void;
|
|
107
107
|
/** Returns current key names stored in persisted storage */
|
|
108
108
|
declare function getAllKeys(): Promise<Set<OnyxKey>>;
|
|
109
|
-
/**
|
|
110
|
-
* Returns set of all registered collection keys
|
|
111
|
-
*/
|
|
112
|
-
declare function getCollectionKeys(): Set<OnyxKey>;
|
|
113
|
-
/**
|
|
114
|
-
* Checks to see if the subscriber's supplied key
|
|
115
|
-
* is associated with a collection of keys.
|
|
116
|
-
*/
|
|
117
|
-
declare function isCollectionKey(key: OnyxKey): key is CollectionKeyBase;
|
|
118
|
-
declare function isCollectionMemberKey<TCollectionKey extends CollectionKeyBase>(collectionKey: TCollectionKey, key: string): key is `${TCollectionKey}${string}`;
|
|
119
|
-
/**
|
|
120
|
-
* Checks if a given key is a collection member key (not just a collection key).
|
|
121
|
-
* @param key - The key to check
|
|
122
|
-
* @returns true if the key is a collection member, false otherwise
|
|
123
|
-
*/
|
|
124
|
-
declare function isCollectionMember(key: OnyxKey): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if a given key is a RAM-only key, RAM-only collection key, or a RAM-only collection member
|
|
127
|
-
*
|
|
128
|
-
* For example:
|
|
129
|
-
*
|
|
130
|
-
* For the following Onyx setup
|
|
131
|
-
*
|
|
132
|
-
* ramOnlyKeys: ["ramOnlyKey", "ramOnlyCollection_"]
|
|
133
|
-
*
|
|
134
|
-
* - `isRamOnlyKey("ramOnlyKey")` would return true
|
|
135
|
-
* - `isRamOnlyKey("ramOnlyCollection_")` would return true
|
|
136
|
-
* - `isRamOnlyKey("ramOnlyCollection_1")` would return true
|
|
137
|
-
* - `isRamOnlyKey("someOtherKey")` would return false
|
|
138
|
-
*
|
|
139
|
-
* @param key - The key to check
|
|
140
|
-
* @returns true if key is a RAM-only key, RAM-only collection key, or a RAM-only collection member
|
|
141
|
-
*/
|
|
142
|
-
declare function isRamOnlyKey(key: OnyxKey): boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Splits a collection member key into the collection key part and the ID part.
|
|
145
|
-
* @param key - The collection member key to split.
|
|
146
|
-
* @param collectionKey - The collection key of the `key` param that can be passed in advance to optimize the function.
|
|
147
|
-
* @returns A tuple where the first element is the collection part and the second element is the ID part,
|
|
148
|
-
* or throws an Error if the key is not a collection one.
|
|
149
|
-
*/
|
|
150
|
-
declare function splitCollectionMemberKey<TKey extends CollectionKey, CollectionKeyType = TKey extends `${infer Prefix}_${string}` ? `${Prefix}_` : never>(key: TKey, collectionKey?: string): [CollectionKeyType, string];
|
|
151
|
-
/**
|
|
152
|
-
* Checks to see if a provided key is the exact configured key of our connected subscriber
|
|
153
|
-
* or if the provided key is a collection member key (in case our configured key is a "collection key")
|
|
154
|
-
*/
|
|
155
|
-
declare function isKeyMatch(configKey: OnyxKey, key: OnyxKey): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Extracts the collection identifier of a given collection member key.
|
|
158
|
-
*
|
|
159
|
-
* For example:
|
|
160
|
-
* - `getCollectionKey("report_123")` would return "report_"
|
|
161
|
-
* - `getCollectionKey("report_")` would return "report_"
|
|
162
|
-
* - `getCollectionKey("report_-1_something")` would return "report_"
|
|
163
|
-
* - `getCollectionKey("sharedNVP_user_-1_something")` would return "sharedNVP_user_"
|
|
164
|
-
*
|
|
165
|
-
* @param key - The collection key to process.
|
|
166
|
-
* @returns The plain collection key or undefined if the key is not a collection one.
|
|
167
|
-
*/
|
|
168
|
-
declare function getCollectionKey(key: CollectionKey): string | undefined;
|
|
169
109
|
/**
|
|
170
110
|
* Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
|
|
171
111
|
* If the requested key is a collection, it will return an object with all the collection members.
|
|
@@ -357,18 +297,11 @@ declare const OnyxUtils: {
|
|
|
357
297
|
sendActionToDevTools: typeof sendActionToDevTools;
|
|
358
298
|
get: typeof get;
|
|
359
299
|
getAllKeys: typeof getAllKeys;
|
|
360
|
-
getCollectionKeys: typeof getCollectionKeys;
|
|
361
|
-
isCollectionKey: typeof isCollectionKey;
|
|
362
|
-
isCollectionMemberKey: typeof isCollectionMemberKey;
|
|
363
|
-
isCollectionMember: typeof isCollectionMember;
|
|
364
|
-
splitCollectionMemberKey: typeof splitCollectionMemberKey;
|
|
365
|
-
isKeyMatch: typeof isKeyMatch;
|
|
366
300
|
tryGetCachedValue: typeof tryGetCachedValue;
|
|
367
301
|
getCachedCollection: typeof getCachedCollection;
|
|
368
302
|
keysChanged: typeof keysChanged;
|
|
369
303
|
keyChanged: typeof keyChanged;
|
|
370
304
|
sendDataToConnection: typeof sendDataToConnection;
|
|
371
|
-
getCollectionKey: typeof getCollectionKey;
|
|
372
305
|
getCollectionDataAndSendAsObject: typeof getCollectionDataAndSendAsObject;
|
|
373
306
|
scheduleSubscriberUpdate: typeof scheduleSubscriberUpdate;
|
|
374
307
|
scheduleNotifyCollectionSubscribers: typeof scheduleNotifyCollectionSubscribers;
|
|
@@ -404,7 +337,6 @@ declare const OnyxUtils: {
|
|
|
404
337
|
setWithRetry: typeof setWithRetry;
|
|
405
338
|
multiSetWithRetry: typeof multiSetWithRetry;
|
|
406
339
|
setCollectionWithRetry: typeof setCollectionWithRetry;
|
|
407
|
-
isRamOnlyKey: typeof isRamOnlyKey;
|
|
408
340
|
};
|
|
409
341
|
export type { OnyxMethod };
|
|
410
342
|
export default OnyxUtils;
|
package/dist/OnyxUtils.js
CHANGED
|
@@ -42,6 +42,7 @@ const underscore_1 = __importDefault(require("underscore"));
|
|
|
42
42
|
const DevTools_1 = __importDefault(require("./DevTools"));
|
|
43
43
|
const Logger = __importStar(require("./Logger"));
|
|
44
44
|
const OnyxCache_1 = __importStar(require("./OnyxCache"));
|
|
45
|
+
const OnyxKeys_1 = __importDefault(require("./OnyxKeys"));
|
|
45
46
|
const Str = __importStar(require("./Str"));
|
|
46
47
|
const storage_1 = __importDefault(require("./storage"));
|
|
47
48
|
const utils_1 = __importDefault(require("./utils"));
|
|
@@ -78,8 +79,6 @@ let mergeQueuePromise = {};
|
|
|
78
79
|
let nextMacrotaskPromise = null;
|
|
79
80
|
// Holds a mapping of all the React components that want their state subscribed to a store key
|
|
80
81
|
let callbackToStateMapping = {};
|
|
81
|
-
// Keeps a copy of the values of the onyx collection keys as a map for faster lookups
|
|
82
|
-
let onyxCollectionKeySet = new Set();
|
|
83
82
|
// Holds a mapping of the connected key to the subscriptionID for faster lookups
|
|
84
83
|
let onyxKeyToSubscriptionIDs = new Map();
|
|
85
84
|
// Optional user-provided key value states set when Onyx initializes or clears
|
|
@@ -174,7 +173,7 @@ function initStoreValues(keys, initialKeyStates, evictableKeys) {
|
|
|
174
173
|
// We need the value of the collection keys later for checking if a
|
|
175
174
|
// key is a collection. We store it in a map for faster lookup.
|
|
176
175
|
const collectionValues = Object.values((_a = keys.COLLECTION) !== null && _a !== void 0 ? _a : {});
|
|
177
|
-
|
|
176
|
+
const collectionKeySet = collectionValues.reduce((acc, val) => {
|
|
178
177
|
acc.add(val);
|
|
179
178
|
return acc;
|
|
180
179
|
}, new Set());
|
|
@@ -184,7 +183,7 @@ function initStoreValues(keys, initialKeyStates, evictableKeys) {
|
|
|
184
183
|
// Let Onyx know about which keys are safe to evict
|
|
185
184
|
OnyxCache_1.default.setEvictionAllowList(evictableKeys);
|
|
186
185
|
// Set collection keys in cache for optimized storage
|
|
187
|
-
OnyxCache_1.default.setCollectionKeys(
|
|
186
|
+
OnyxCache_1.default.setCollectionKeys(collectionKeySet);
|
|
188
187
|
if (typeof keys.COLLECTION === 'object' && typeof keys.COLLECTION.SNAPSHOT === 'string') {
|
|
189
188
|
snapshotKey = keys.COLLECTION.SNAPSHOT;
|
|
190
189
|
}
|
|
@@ -213,7 +212,7 @@ function get(key) {
|
|
|
213
212
|
// RAM-only keys should never read from storage (they may have stale persisted data
|
|
214
213
|
// from before the key was migrated to RAM-only). Mark as nullish so future get() calls
|
|
215
214
|
// short-circuit via hasCacheForKey and avoid re-running this branch.
|
|
216
|
-
if (isRamOnlyKey(key)) {
|
|
215
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
217
216
|
OnyxCache_1.default.addNullishStorageKey(key);
|
|
218
217
|
return Promise.resolve(undefined);
|
|
219
218
|
}
|
|
@@ -227,7 +226,7 @@ function get(key) {
|
|
|
227
226
|
.then((val) => {
|
|
228
227
|
if (skippableCollectionMemberIDs.size) {
|
|
229
228
|
try {
|
|
230
|
-
const [, collectionMemberID] = splitCollectionMemberKey(key);
|
|
229
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key);
|
|
231
230
|
if (skippableCollectionMemberIDs.has(collectionMemberID)) {
|
|
232
231
|
// The key is a skippable one, so we set the value to undefined.
|
|
233
232
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -269,7 +268,7 @@ function multiGet(keys) {
|
|
|
269
268
|
for (const key of keys) {
|
|
270
269
|
// RAM-only keys should never read from storage as they may have stale persisted data
|
|
271
270
|
// from before the key was migrated to RAM-only.
|
|
272
|
-
if (isRamOnlyKey(key)) {
|
|
271
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
273
272
|
if (OnyxCache_1.default.hasCacheForKey(key)) {
|
|
274
273
|
dataMap.set(key, OnyxCache_1.default.get(key));
|
|
275
274
|
}
|
|
@@ -314,7 +313,7 @@ function multiGet(keys) {
|
|
|
314
313
|
for (const [key, value] of values) {
|
|
315
314
|
if (skippableCollectionMemberIDs.size) {
|
|
316
315
|
try {
|
|
317
|
-
const [, collectionMemberID] = splitCollectionMemberKey(key);
|
|
316
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key);
|
|
318
317
|
if (skippableCollectionMemberIDs.has(collectionMemberID)) {
|
|
319
318
|
// The key is a skippable one, so we skip this iteration.
|
|
320
319
|
continue;
|
|
@@ -380,126 +379,20 @@ function getAllKeys() {
|
|
|
380
379
|
const promise = storage_1.default.getAllKeys().then((keys) => {
|
|
381
380
|
// Filter out RAM-only keys from storage results as they may be stale entries
|
|
382
381
|
// from before the key was migrated to RAM-only.
|
|
383
|
-
const filteredKeys = keys.filter((key) => !isRamOnlyKey(key));
|
|
382
|
+
const filteredKeys = keys.filter((key) => !OnyxKeys_1.default.isRamOnlyKey(key));
|
|
384
383
|
OnyxCache_1.default.setAllKeys(filteredKeys);
|
|
385
384
|
// return the updated set of keys
|
|
386
385
|
return OnyxCache_1.default.getAllKeys();
|
|
387
386
|
});
|
|
388
387
|
return OnyxCache_1.default.captureTask(OnyxCache_1.TASK.GET_ALL_KEYS, promise);
|
|
389
388
|
}
|
|
390
|
-
/**
|
|
391
|
-
* Returns set of all registered collection keys
|
|
392
|
-
*/
|
|
393
|
-
function getCollectionKeys() {
|
|
394
|
-
return onyxCollectionKeySet;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Checks to see if the subscriber's supplied key
|
|
398
|
-
* is associated with a collection of keys.
|
|
399
|
-
*/
|
|
400
|
-
function isCollectionKey(key) {
|
|
401
|
-
return onyxCollectionKeySet.has(key);
|
|
402
|
-
}
|
|
403
|
-
function isCollectionMemberKey(collectionKey, key) {
|
|
404
|
-
return key.startsWith(collectionKey) && key.length > collectionKey.length;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Checks if a given key is a collection member key (not just a collection key).
|
|
408
|
-
* @param key - The key to check
|
|
409
|
-
* @returns true if the key is a collection member, false otherwise
|
|
410
|
-
*/
|
|
411
|
-
function isCollectionMember(key) {
|
|
412
|
-
const collectionKey = getCollectionKey(key);
|
|
413
|
-
// If the key is longer than the collection key, it's a collection member
|
|
414
|
-
return !!collectionKey && key.length > collectionKey.length;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Checks if a given key is a RAM-only key, RAM-only collection key, or a RAM-only collection member
|
|
418
|
-
*
|
|
419
|
-
* For example:
|
|
420
|
-
*
|
|
421
|
-
* For the following Onyx setup
|
|
422
|
-
*
|
|
423
|
-
* ramOnlyKeys: ["ramOnlyKey", "ramOnlyCollection_"]
|
|
424
|
-
*
|
|
425
|
-
* - `isRamOnlyKey("ramOnlyKey")` would return true
|
|
426
|
-
* - `isRamOnlyKey("ramOnlyCollection_")` would return true
|
|
427
|
-
* - `isRamOnlyKey("ramOnlyCollection_1")` would return true
|
|
428
|
-
* - `isRamOnlyKey("someOtherKey")` would return false
|
|
429
|
-
*
|
|
430
|
-
* @param key - The key to check
|
|
431
|
-
* @returns true if key is a RAM-only key, RAM-only collection key, or a RAM-only collection member
|
|
432
|
-
*/
|
|
433
|
-
function isRamOnlyKey(key) {
|
|
434
|
-
const collectionKey = getCollectionKey(key);
|
|
435
|
-
if (collectionKey) {
|
|
436
|
-
return OnyxCache_1.default.isRamOnlyKey(collectionKey);
|
|
437
|
-
}
|
|
438
|
-
return OnyxCache_1.default.isRamOnlyKey(key);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Splits a collection member key into the collection key part and the ID part.
|
|
442
|
-
* @param key - The collection member key to split.
|
|
443
|
-
* @param collectionKey - The collection key of the `key` param that can be passed in advance to optimize the function.
|
|
444
|
-
* @returns A tuple where the first element is the collection part and the second element is the ID part,
|
|
445
|
-
* or throws an Error if the key is not a collection one.
|
|
446
|
-
*/
|
|
447
|
-
function splitCollectionMemberKey(key, collectionKey) {
|
|
448
|
-
if (collectionKey && !isCollectionMemberKey(collectionKey, key)) {
|
|
449
|
-
throw new Error(`Invalid '${collectionKey}' collection key provided, it isn't compatible with '${key}' key.`);
|
|
450
|
-
}
|
|
451
|
-
if (!collectionKey) {
|
|
452
|
-
const resolvedKey = getCollectionKey(key);
|
|
453
|
-
if (!resolvedKey) {
|
|
454
|
-
throw new Error(`Invalid '${key}' key provided, only collection keys are allowed.`);
|
|
455
|
-
}
|
|
456
|
-
// eslint-disable-next-line no-param-reassign
|
|
457
|
-
collectionKey = resolvedKey;
|
|
458
|
-
}
|
|
459
|
-
return [collectionKey, key.slice(collectionKey.length)];
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Checks to see if a provided key is the exact configured key of our connected subscriber
|
|
463
|
-
* or if the provided key is a collection member key (in case our configured key is a "collection key")
|
|
464
|
-
*/
|
|
465
|
-
function isKeyMatch(configKey, key) {
|
|
466
|
-
return isCollectionKey(configKey) ? Str.startsWith(key, configKey) : configKey === key;
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Extracts the collection identifier of a given collection member key.
|
|
470
|
-
*
|
|
471
|
-
* For example:
|
|
472
|
-
* - `getCollectionKey("report_123")` would return "report_"
|
|
473
|
-
* - `getCollectionKey("report_")` would return "report_"
|
|
474
|
-
* - `getCollectionKey("report_-1_something")` would return "report_"
|
|
475
|
-
* - `getCollectionKey("sharedNVP_user_-1_something")` would return "sharedNVP_user_"
|
|
476
|
-
*
|
|
477
|
-
* @param key - The collection key to process.
|
|
478
|
-
* @returns The plain collection key or undefined if the key is not a collection one.
|
|
479
|
-
*/
|
|
480
|
-
function getCollectionKey(key) {
|
|
481
|
-
// Start by finding the position of the last underscore in the string
|
|
482
|
-
let lastUnderscoreIndex = key.lastIndexOf('_');
|
|
483
|
-
// Iterate backwards to find the longest key that ends with '_'
|
|
484
|
-
while (lastUnderscoreIndex > 0) {
|
|
485
|
-
const possibleKey = key.slice(0, lastUnderscoreIndex + 1);
|
|
486
|
-
// Check if the substring is a key in the Set
|
|
487
|
-
if (isCollectionKey(possibleKey)) {
|
|
488
|
-
// Return the matching key and the rest of the string
|
|
489
|
-
return possibleKey;
|
|
490
|
-
}
|
|
491
|
-
// Move to the next underscore to check smaller possible keys
|
|
492
|
-
lastUnderscoreIndex = key.lastIndexOf('_', lastUnderscoreIndex - 1);
|
|
493
|
-
}
|
|
494
|
-
return undefined;
|
|
495
|
-
}
|
|
496
389
|
/**
|
|
497
390
|
* Tries to get a value from the cache. If the value is not present in cache it will return the default value or undefined.
|
|
498
391
|
* If the requested key is a collection, it will return an object with all the collection members.
|
|
499
392
|
*/
|
|
500
393
|
function tryGetCachedValue(key) {
|
|
501
394
|
let val = OnyxCache_1.default.get(key);
|
|
502
|
-
if (isCollectionKey(key)) {
|
|
395
|
+
if (OnyxKeys_1.default.isCollectionKey(key)) {
|
|
503
396
|
const collectionData = OnyxCache_1.default.getCollectionData(key);
|
|
504
397
|
if (collectionData !== undefined) {
|
|
505
398
|
val = collectionData;
|
|
@@ -543,7 +436,7 @@ function getCachedCollection(collectionKey, collectionMemberKeys) {
|
|
|
543
436
|
// If we don't have collectionMemberKeys array then we have to check whether a key is a collection member key.
|
|
544
437
|
// Because in that case the keys will be coming from `cache.getAllKeys()` and we need to filter out the keys that
|
|
545
438
|
// are not part of the collection.
|
|
546
|
-
if (!collectionMemberKeys && !isCollectionMemberKey(collectionKey, key)) {
|
|
439
|
+
if (!collectionMemberKeys && !OnyxKeys_1.default.isCollectionMemberKey(collectionKey, key)) {
|
|
547
440
|
continue;
|
|
548
441
|
}
|
|
549
442
|
const cachedValue = OnyxCache_1.default.get(key);
|
|
@@ -582,7 +475,7 @@ function keysChanged(collectionKey, partialCollection, partialPreviousCollection
|
|
|
582
475
|
/**
|
|
583
476
|
* e.g. Onyx.connect({key: `${ONYXKEYS.COLLECTION.REPORT}{reportID}`, callback: ...});
|
|
584
477
|
*/
|
|
585
|
-
const isSubscribedToCollectionMemberKey = isCollectionMemberKey(collectionKey, subscriber.key);
|
|
478
|
+
const isSubscribedToCollectionMemberKey = OnyxKeys_1.default.isCollectionMemberKey(collectionKey, subscriber.key);
|
|
586
479
|
// Regular Onyx.connect() subscriber found.
|
|
587
480
|
if (typeof subscriber.callback === 'function') {
|
|
588
481
|
// If they are subscribed to the collection key and using waitForCollectionCallback then we'll
|
|
@@ -628,7 +521,7 @@ function keyChanged(key, value, canUpdateSubscriber = () => true, isProcessingCo
|
|
|
628
521
|
var _a, _b;
|
|
629
522
|
// Add or remove this key from the recentlyAccessedKeys lists
|
|
630
523
|
if (value !== null) {
|
|
631
|
-
OnyxCache_1.default.addLastAccessedKey(key, isCollectionKey(key));
|
|
524
|
+
OnyxCache_1.default.addLastAccessedKey(key, OnyxKeys_1.default.isCollectionKey(key));
|
|
632
525
|
}
|
|
633
526
|
else {
|
|
634
527
|
OnyxCache_1.default.removeLastAccessedKey(key);
|
|
@@ -639,7 +532,7 @@ function keyChanged(key, value, canUpdateSubscriber = () => true, isProcessingCo
|
|
|
639
532
|
// do the same in keysChanged, because we only call that function when a collection key changes, and it doesn't happen that often.
|
|
640
533
|
// For performance reason, we look for the given key and later if don't find it we look for the collection key, instead of checking if it is a collection key first.
|
|
641
534
|
let stateMappingKeys = (_a = onyxKeyToSubscriptionIDs.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
642
|
-
const collectionKey = getCollectionKey(key);
|
|
535
|
+
const collectionKey = OnyxKeys_1.default.getCollectionKey(key);
|
|
643
536
|
if (collectionKey) {
|
|
644
537
|
// Getting the collection key from the specific key because only collection keys were stored in the mapping.
|
|
645
538
|
stateMappingKeys = [...stateMappingKeys, ...((_b = onyxKeyToSubscriptionIDs.get(collectionKey)) !== null && _b !== void 0 ? _b : [])];
|
|
@@ -650,7 +543,7 @@ function keyChanged(key, value, canUpdateSubscriber = () => true, isProcessingCo
|
|
|
650
543
|
const cachedCollections = {};
|
|
651
544
|
for (const stateMappingKey of stateMappingKeys) {
|
|
652
545
|
const subscriber = callbackToStateMapping[stateMappingKey];
|
|
653
|
-
if (!subscriber || !isKeyMatch(subscriber.key, key) || !canUpdateSubscriber(subscriber)) {
|
|
546
|
+
if (!subscriber || !OnyxKeys_1.default.isKeyMatch(subscriber.key, key) || !canUpdateSubscriber(subscriber)) {
|
|
654
547
|
continue;
|
|
655
548
|
}
|
|
656
549
|
// Subscriber is a regular call to connect() and provided a callback
|
|
@@ -658,7 +551,7 @@ function keyChanged(key, value, canUpdateSubscriber = () => true, isProcessingCo
|
|
|
658
551
|
if (lastConnectionCallbackData.has(subscriber.subscriptionID) && lastConnectionCallbackData.get(subscriber.subscriptionID) === value) {
|
|
659
552
|
continue;
|
|
660
553
|
}
|
|
661
|
-
if (isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) {
|
|
554
|
+
if (OnyxKeys_1.default.isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) {
|
|
662
555
|
// Skip individual key changes for collection callbacks during collection updates
|
|
663
556
|
// to prevent duplicate callbacks - the collection update will handle this properly
|
|
664
557
|
if (isProcessingCollectionUpdate) {
|
|
@@ -762,7 +655,7 @@ function scheduleNotifyCollectionSubscribers(key, value, previousValue) {
|
|
|
762
655
|
function remove(key, isProcessingCollectionUpdate) {
|
|
763
656
|
OnyxCache_1.default.drop(key);
|
|
764
657
|
scheduleSubscriberUpdate(key, undefined, undefined, isProcessingCollectionUpdate);
|
|
765
|
-
if (isRamOnlyKey(key)) {
|
|
658
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
766
659
|
return Promise.resolve();
|
|
767
660
|
}
|
|
768
661
|
return storage_1.default.removeItem(key).then(() => undefined);
|
|
@@ -918,12 +811,12 @@ function initializeWithDefaultKeyStates() {
|
|
|
918
811
|
for (const [key, value] of pairs) {
|
|
919
812
|
// RAM-only keys should not be cached from storage as they may have stale persisted data
|
|
920
813
|
// from before the key was migrated to RAM-only.
|
|
921
|
-
if (isRamOnlyKey(key)) {
|
|
814
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
922
815
|
continue;
|
|
923
816
|
}
|
|
924
817
|
// Skip collection members that are marked as skippable
|
|
925
|
-
if (skippableCollectionMemberIDs.size && getCollectionKey(key)) {
|
|
926
|
-
const [, collectionMemberID] = splitCollectionMemberKey(key);
|
|
818
|
+
if (skippableCollectionMemberIDs.size && OnyxKeys_1.default.getCollectionKey(key)) {
|
|
819
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key);
|
|
927
820
|
if (skippableCollectionMemberIDs.has(collectionMemberID)) {
|
|
928
821
|
continue;
|
|
929
822
|
}
|
|
@@ -981,7 +874,7 @@ function isValidNonEmptyCollectionForMerge(collection) {
|
|
|
981
874
|
function doAllCollectionItemsBelongToSameParent(collectionKey, collectionKeys) {
|
|
982
875
|
let hasCollectionKeyCheckFailed = false;
|
|
983
876
|
for (const dataKey of collectionKeys) {
|
|
984
|
-
if (isKeyMatch(collectionKey, dataKey)) {
|
|
877
|
+
if (OnyxKeys_1.default.isKeyMatch(collectionKey, dataKey)) {
|
|
985
878
|
continue;
|
|
986
879
|
}
|
|
987
880
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -1017,7 +910,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1017
910
|
// Performance improvement
|
|
1018
911
|
// If the mapping is connected to an onyx key that is not a collection
|
|
1019
912
|
// we can skip the call to getAllKeys() and return an array with a single item
|
|
1020
|
-
if (!!mapping.key && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && OnyxCache_1.default.getAllKeys().has(mapping.key)) {
|
|
913
|
+
if (!!mapping.key && typeof mapping.key === 'string' && !OnyxKeys_1.default.isCollectionKey(mapping.key) && OnyxCache_1.default.getAllKeys().has(mapping.key)) {
|
|
1021
914
|
return new Set([mapping.key]);
|
|
1022
915
|
}
|
|
1023
916
|
return getAllKeys();
|
|
@@ -1028,7 +921,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1028
921
|
// subscribed to a "collection key" or a single key.
|
|
1029
922
|
const matchingKeys = [];
|
|
1030
923
|
// Performance optimization: For single key subscriptions, avoid O(n) iteration
|
|
1031
|
-
if (!isCollectionKey(mapping.key)) {
|
|
924
|
+
if (!OnyxKeys_1.default.isCollectionKey(mapping.key)) {
|
|
1032
925
|
if (keys.has(mapping.key)) {
|
|
1033
926
|
matchingKeys.push(mapping.key);
|
|
1034
927
|
}
|
|
@@ -1036,7 +929,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1036
929
|
else {
|
|
1037
930
|
// Collection case - need to iterate through all keys to find matches (O(n))
|
|
1038
931
|
for (const key of keys) {
|
|
1039
|
-
if (!isKeyMatch(mapping.key, key)) {
|
|
932
|
+
if (!OnyxKeys_1.default.isKeyMatch(mapping.key, key)) {
|
|
1040
933
|
continue;
|
|
1041
934
|
}
|
|
1042
935
|
matchingKeys.push(key);
|
|
@@ -1049,7 +942,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1049
942
|
if (mapping.key) {
|
|
1050
943
|
OnyxCache_1.default.addNullishStorageKey(mapping.key);
|
|
1051
944
|
}
|
|
1052
|
-
const matchedKey = isCollectionKey(mapping.key) && mapping.waitForCollectionCallback ? mapping.key : undefined;
|
|
945
|
+
const matchedKey = OnyxKeys_1.default.isCollectionKey(mapping.key) && mapping.waitForCollectionCallback ? mapping.key : undefined;
|
|
1053
946
|
// Here we cannot use batching because the nullish value is expected to be set immediately for default props
|
|
1054
947
|
// or they will be undefined.
|
|
1055
948
|
sendDataToConnection(mapping, null, matchedKey);
|
|
@@ -1059,7 +952,7 @@ function subscribeToKey(connectOptions) {
|
|
|
1059
952
|
// into an object and just make a single call. The latter behavior is enabled by providing a waitForCollectionCallback key
|
|
1060
953
|
// combined with a subscription to a collection key.
|
|
1061
954
|
if (typeof mapping.callback === 'function') {
|
|
1062
|
-
if (isCollectionKey(mapping.key)) {
|
|
955
|
+
if (OnyxKeys_1.default.isCollectionKey(mapping.key)) {
|
|
1063
956
|
if (mapping.waitForCollectionCallback) {
|
|
1064
957
|
getCollectionDataAndSendAsObject(matchingKeys, mapping);
|
|
1065
958
|
return;
|
|
@@ -1091,7 +984,7 @@ function unsubscribeFromKey(subscriptionID) {
|
|
|
1091
984
|
if (!callbackToStateMapping[subscriptionID]) {
|
|
1092
985
|
return;
|
|
1093
986
|
}
|
|
1094
|
-
deleteKeyBySubscriptions(
|
|
987
|
+
deleteKeyBySubscriptions(subscriptionID);
|
|
1095
988
|
delete callbackToStateMapping[subscriptionID];
|
|
1096
989
|
}
|
|
1097
990
|
function updateSnapshots(data, mergeFn) {
|
|
@@ -1108,7 +1001,7 @@ function updateSnapshots(data, mergeFn) {
|
|
|
1108
1001
|
let updatedData = {};
|
|
1109
1002
|
for (const { key, value } of data) {
|
|
1110
1003
|
// snapshots are normal keys so we want to skip update if they are written to Onyx
|
|
1111
|
-
if (isCollectionMemberKey(snapshotCollectionKey, key)) {
|
|
1004
|
+
if (OnyxKeys_1.default.isCollectionMemberKey(snapshotCollectionKey, key)) {
|
|
1112
1005
|
continue;
|
|
1113
1006
|
}
|
|
1114
1007
|
if (typeof snapshotEntryValue !== 'object' || !('data' in snapshotEntryValue)) {
|
|
@@ -1164,7 +1057,7 @@ function setWithRetry({ key, value, options }, retryAttempt) {
|
|
|
1164
1057
|
}
|
|
1165
1058
|
if (skippableCollectionMemberIDs.size) {
|
|
1166
1059
|
try {
|
|
1167
|
-
const [, collectionMemberID] =
|
|
1060
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key);
|
|
1168
1061
|
if (skippableCollectionMemberIDs.has(collectionMemberID)) {
|
|
1169
1062
|
// The key is a skippable one, so we set the new value to null.
|
|
1170
1063
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1213,7 +1106,7 @@ function setWithRetry({ key, value, options }, retryAttempt) {
|
|
|
1213
1106
|
return updatePromise;
|
|
1214
1107
|
}
|
|
1215
1108
|
// If a key is a RAM-only key or a member of RAM-only collection, we skip the step that modifies the storage
|
|
1216
|
-
if (isRamOnlyKey(key)) {
|
|
1109
|
+
if (OnyxKeys_1.default.isRamOnlyKey(key)) {
|
|
1217
1110
|
OnyxUtils.sendActionToDevTools(OnyxUtils.METHOD.SET, key, valueWithoutNestedNullValues);
|
|
1218
1111
|
return updatePromise;
|
|
1219
1112
|
}
|
|
@@ -1237,7 +1130,7 @@ function multiSetWithRetry(data, retryAttempt) {
|
|
|
1237
1130
|
if (skippableCollectionMemberIDs.size) {
|
|
1238
1131
|
newData = Object.keys(newData).reduce((result, key) => {
|
|
1239
1132
|
try {
|
|
1240
|
-
const [, collectionMemberID] =
|
|
1133
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key);
|
|
1241
1134
|
// If the collection member key is a skippable one we set its value to null.
|
|
1242
1135
|
// eslint-disable-next-line no-param-reassign
|
|
1243
1136
|
result[key] = !skippableCollectionMemberIDs.has(collectionMemberID) ? newData[key] : null;
|
|
@@ -1264,7 +1157,7 @@ function multiSetWithRetry(data, retryAttempt) {
|
|
|
1264
1157
|
const keyValuePairsToStore = keyValuePairsToSet.filter((keyValuePair) => {
|
|
1265
1158
|
const [key] = keyValuePair;
|
|
1266
1159
|
// Filter out the RAM-only key value pairs, as they should not be saved to storage
|
|
1267
|
-
return !isRamOnlyKey(key);
|
|
1160
|
+
return !OnyxKeys_1.default.isRamOnlyKey(key);
|
|
1268
1161
|
});
|
|
1269
1162
|
return storage_1.default.multiSet(keyValuePairsToStore)
|
|
1270
1163
|
.catch((error) => OnyxUtils.retryOperation(error, multiSetWithRetry, newData, retryAttempt))
|
|
@@ -1296,7 +1189,7 @@ function setCollectionWithRetry({ collectionKey, collection }, retryAttempt) {
|
|
|
1296
1189
|
if (skippableCollectionMemberIDs.size) {
|
|
1297
1190
|
resultCollection = resultCollectionKeys.reduce((result, key) => {
|
|
1298
1191
|
try {
|
|
1299
|
-
const [, collectionMemberID] =
|
|
1192
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key, collectionKey);
|
|
1300
1193
|
// If the collection member key is a skippable one we set its value to null.
|
|
1301
1194
|
// eslint-disable-next-line no-param-reassign
|
|
1302
1195
|
result[key] = !skippableCollectionMemberIDs.has(collectionMemberID) ? resultCollection[key] : null;
|
|
@@ -1327,7 +1220,7 @@ function setCollectionWithRetry({ collectionKey, collection }, retryAttempt) {
|
|
|
1327
1220
|
OnyxCache_1.default.set(key, value);
|
|
1328
1221
|
const updatePromise = OnyxUtils.scheduleNotifyCollectionSubscribers(collectionKey, mutableCollection, previousCollection);
|
|
1329
1222
|
// RAM-only keys are not supposed to be saved to storage
|
|
1330
|
-
if (isRamOnlyKey(collectionKey)) {
|
|
1223
|
+
if (OnyxKeys_1.default.isRamOnlyKey(collectionKey)) {
|
|
1331
1224
|
OnyxUtils.sendActionToDevTools(OnyxUtils.METHOD.SET_COLLECTION, undefined, mutableCollection);
|
|
1332
1225
|
return updatePromise;
|
|
1333
1226
|
}
|
|
@@ -1366,7 +1259,7 @@ function mergeCollectionWithPatches({ collectionKey, collection, mergeReplaceNul
|
|
|
1366
1259
|
if (skippableCollectionMemberIDs.size) {
|
|
1367
1260
|
resultCollection = resultCollectionKeys.reduce((result, key) => {
|
|
1368
1261
|
try {
|
|
1369
|
-
const [, collectionMemberID] = splitCollectionMemberKey(key, collectionKey);
|
|
1262
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key, collectionKey);
|
|
1370
1263
|
// If the collection member key is a skippable one we set its value to null.
|
|
1371
1264
|
// eslint-disable-next-line no-param-reassign
|
|
1372
1265
|
result[key] = !skippableCollectionMemberIDs.has(collectionMemberID) ? resultCollection[key] : null;
|
|
@@ -1429,11 +1322,11 @@ function mergeCollectionWithPatches({ collectionKey, collection, mergeReplaceNul
|
|
|
1429
1322
|
// New keys will be added via multiSet while existing keys will be updated using multiMerge
|
|
1430
1323
|
// This is because setting a key that doesn't exist yet with multiMerge will throw errors
|
|
1431
1324
|
// We can skip this step for RAM-only keys as they should never be saved to storage
|
|
1432
|
-
if (!isRamOnlyKey(collectionKey) && keyValuePairsForExistingCollection.length > 0) {
|
|
1325
|
+
if (!OnyxKeys_1.default.isRamOnlyKey(collectionKey) && keyValuePairsForExistingCollection.length > 0) {
|
|
1433
1326
|
promises.push(storage_1.default.multiMerge(keyValuePairsForExistingCollection));
|
|
1434
1327
|
}
|
|
1435
1328
|
// We can skip this step for RAM-only keys as they should never be saved to storage
|
|
1436
|
-
if (!isRamOnlyKey(collectionKey) && keyValuePairsForNewCollection.length > 0) {
|
|
1329
|
+
if (!OnyxKeys_1.default.isRamOnlyKey(collectionKey) && keyValuePairsForNewCollection.length > 0) {
|
|
1437
1330
|
promises.push(storage_1.default.multiSet(keyValuePairsForNewCollection));
|
|
1438
1331
|
}
|
|
1439
1332
|
// finalMergedCollection contains all the keys that were merged, without the keys of incompatible updates
|
|
@@ -1474,7 +1367,7 @@ function partialSetCollection({ collectionKey, collection }, retryAttempt) {
|
|
|
1474
1367
|
if (skippableCollectionMemberIDs.size) {
|
|
1475
1368
|
resultCollection = resultCollectionKeys.reduce((result, key) => {
|
|
1476
1369
|
try {
|
|
1477
|
-
const [, collectionMemberID] = splitCollectionMemberKey(key, collectionKey);
|
|
1370
|
+
const [, collectionMemberID] = OnyxKeys_1.default.splitCollectionMemberKey(key, collectionKey);
|
|
1478
1371
|
// If the collection member key is a skippable one we set its value to null.
|
|
1479
1372
|
// eslint-disable-next-line no-param-reassign
|
|
1480
1373
|
result[key] = !skippableCollectionMemberIDs.has(collectionMemberID) ? resultCollection[key] : null;
|
|
@@ -1496,7 +1389,7 @@ function partialSetCollection({ collectionKey, collection }, retryAttempt) {
|
|
|
1496
1389
|
for (const [key, value] of keyValuePairs)
|
|
1497
1390
|
OnyxCache_1.default.set(key, value);
|
|
1498
1391
|
const updatePromise = scheduleNotifyCollectionSubscribers(collectionKey, mutableCollection, previousCollection);
|
|
1499
|
-
if (isRamOnlyKey(collectionKey)) {
|
|
1392
|
+
if (OnyxKeys_1.default.isRamOnlyKey(collectionKey)) {
|
|
1500
1393
|
sendActionToDevTools(METHOD.SET_COLLECTION, undefined, mutableCollection);
|
|
1501
1394
|
return updatePromise;
|
|
1502
1395
|
}
|
|
@@ -1535,18 +1428,11 @@ const OnyxUtils = {
|
|
|
1535
1428
|
sendActionToDevTools,
|
|
1536
1429
|
get,
|
|
1537
1430
|
getAllKeys,
|
|
1538
|
-
getCollectionKeys,
|
|
1539
|
-
isCollectionKey,
|
|
1540
|
-
isCollectionMemberKey,
|
|
1541
|
-
isCollectionMember,
|
|
1542
|
-
splitCollectionMemberKey,
|
|
1543
|
-
isKeyMatch,
|
|
1544
1431
|
tryGetCachedValue,
|
|
1545
1432
|
getCachedCollection,
|
|
1546
1433
|
keysChanged,
|
|
1547
1434
|
keyChanged,
|
|
1548
1435
|
sendDataToConnection,
|
|
1549
|
-
getCollectionKey,
|
|
1550
1436
|
getCollectionDataAndSendAsObject,
|
|
1551
1437
|
scheduleSubscriberUpdate,
|
|
1552
1438
|
scheduleNotifyCollectionSubscribers,
|
|
@@ -1582,7 +1468,6 @@ const OnyxUtils = {
|
|
|
1582
1468
|
setWithRetry,
|
|
1583
1469
|
multiSetWithRetry,
|
|
1584
1470
|
setCollectionWithRetry,
|
|
1585
|
-
isRamOnlyKey,
|
|
1586
1471
|
};
|
|
1587
1472
|
GlobalSettings.addGlobalSettingsChangeListener(({ enablePerformanceMetrics }) => {
|
|
1588
1473
|
if (!enablePerformanceMetrics) {
|
|
@@ -1596,8 +1481,6 @@ GlobalSettings.addGlobalSettingsChangeListener(({ enablePerformanceMetrics }) =>
|
|
|
1596
1481
|
// @ts-expect-error Reassign
|
|
1597
1482
|
getAllKeys = (0, metrics_1.default)(getAllKeys, 'OnyxUtils.getAllKeys');
|
|
1598
1483
|
// @ts-expect-error Reassign
|
|
1599
|
-
getCollectionKeys = (0, metrics_1.default)(getCollectionKeys, 'OnyxUtils.getCollectionKeys');
|
|
1600
|
-
// @ts-expect-error Reassign
|
|
1601
1484
|
keysChanged = (0, metrics_1.default)(keysChanged, 'OnyxUtils.keysChanged');
|
|
1602
1485
|
// @ts-expect-error Reassign
|
|
1603
1486
|
keyChanged = (0, metrics_1.default)(keyChanged, 'OnyxUtils.keyChanged');
|
package/dist/useOnyx.js
CHANGED
|
@@ -41,6 +41,7 @@ const react_1 = require("react");
|
|
|
41
41
|
const OnyxCache_1 = __importStar(require("./OnyxCache"));
|
|
42
42
|
const OnyxConnectionManager_1 = __importDefault(require("./OnyxConnectionManager"));
|
|
43
43
|
const OnyxUtils_1 = __importDefault(require("./OnyxUtils"));
|
|
44
|
+
const OnyxKeys_1 = __importDefault(require("./OnyxKeys"));
|
|
44
45
|
const GlobalSettings = __importStar(require("./GlobalSettings"));
|
|
45
46
|
const usePrevious_1 = __importDefault(require("./usePrevious"));
|
|
46
47
|
const metrics_1 = __importDefault(require("./metrics"));
|
|
@@ -251,7 +252,7 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
251
252
|
onStoreChange();
|
|
252
253
|
},
|
|
253
254
|
initWithStoredValues: options === null || options === void 0 ? void 0 : options.initWithStoredValues,
|
|
254
|
-
waitForCollectionCallback:
|
|
255
|
+
waitForCollectionCallback: OnyxKeys_1.default.isCollectionKey(key),
|
|
255
256
|
reuseConnection: options === null || options === void 0 ? void 0 : options.reuseConnection,
|
|
256
257
|
});
|
|
257
258
|
checkEvictableKey();
|