|
1 | | -/* eslint-disable @typescript-eslint/prefer-for-of */ |
2 | 1 | /* eslint-disable no-continue */ |
3 | 2 | import {deepEqual} from 'fast-equals'; |
4 | 3 | import lodashClone from 'lodash/clone'; |
@@ -664,8 +663,9 @@ function keysChanged<TKey extends CollectionKeyBase>( |
664 | 663 | // and does not represent all of the combined keys and values for a collection key. It is just the "new" data that was merged in via mergeCollection(). |
665 | 664 | const stateMappingKeys = Object.keys(callbackToStateMapping); |
666 | 665 | const collectionKeyLength = collectionKey.length; |
667 | | - for (let i = 0; i < stateMappingKeys.length; i++) { |
668 | | - const subscriber = callbackToStateMapping[stateMappingKeys[i]]; |
| 666 | + |
| 667 | + for (const stateMappingKey of stateMappingKeys) { |
| 668 | + const subscriber = callbackToStateMapping[stateMappingKey]; |
669 | 669 | if (!subscriber) { |
670 | 670 | continue; |
671 | 671 | } |
@@ -702,9 +702,7 @@ function keysChanged<TKey extends CollectionKeyBase>( |
702 | 702 | // If they are not using waitForCollectionCallback then we notify the subscriber with |
703 | 703 | // the new merged data but only for any keys in the partial collection. |
704 | 704 | const dataKeys = Object.keys(partialCollection ?? {}); |
705 | | - for (let j = 0; j < dataKeys.length; j++) { |
706 | | - const dataKey = dataKeys[j]; |
707 | | - |
| 705 | + for (const dataKey of dataKeys) { |
708 | 706 | if (deepEqual(cachedCollection[dataKey], previousCollection[dataKey])) { |
709 | 707 | continue; |
710 | 708 | } |
@@ -761,8 +759,7 @@ function keysChanged<TKey extends CollectionKeyBase>( |
761 | 759 | const prevCollection = prevState?.[subscriber.statePropertyName] ?? {}; |
762 | 760 | const finalCollection = lodashClone(prevCollection); |
763 | 761 | const dataKeys = Object.keys(partialCollection ?? {}); |
764 | | - for (let j = 0; j < dataKeys.length; j++) { |
765 | | - const dataKey = dataKeys[j]; |
| 762 | + for (const dataKey of dataKeys) { |
766 | 763 | finalCollection[dataKey] = cachedCollection[dataKey]; |
767 | 764 | } |
768 | 765 |
|
@@ -881,8 +878,8 @@ function keyChanged<TKey extends OnyxKey>( |
881 | 878 |
|
882 | 879 | const cachedCollections: Record<string, ReturnType<typeof getCachedCollection>> = {}; |
883 | 880 |
|
884 | | - for (let i = 0; i < stateMappingKeys.length; i++) { |
885 | | - const subscriber = callbackToStateMapping[stateMappingKeys[i]]; |
| 881 | + for (const stateMappingKey of stateMappingKeys) { |
| 882 | + const subscriber = callbackToStateMapping[stateMappingKey]; |
886 | 883 | if (!subscriber || !isKeyMatch(subscriber.key, key) || !canUpdateSubscriber(subscriber)) { |
887 | 884 | continue; |
888 | 885 | } |
@@ -1346,7 +1343,7 @@ function subscribeToKey<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKe |
1346 | 1343 | // Performance improvement |
1347 | 1344 | // If the mapping is connected to an onyx key that is not a collection |
1348 | 1345 | // we can skip the call to getAllKeys() and return an array with a single item |
1349 | | - if (Boolean(mapping.key) && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && cache.getAllKeys().has(mapping.key)) { |
| 1346 | + if (!!mapping.key && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && cache.getAllKeys().has(mapping.key)) { |
1350 | 1347 | return new Set([mapping.key]); |
1351 | 1348 | } |
1352 | 1349 | return getAllKeys(); |
|
0 commit comments