|
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'; |
@@ -602,8 +601,9 @@ function keysChanged<TKey extends CollectionKeyBase>( |
602 | 601 | // 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(). |
603 | 602 | const stateMappingKeys = Object.keys(callbackToStateMapping); |
604 | 603 | const collectionKeyLength = collectionKey.length; |
605 | | - for (let i = 0; i < stateMappingKeys.length; i++) { |
606 | | - const subscriber = callbackToStateMapping[stateMappingKeys[i]]; |
| 604 | + |
| 605 | + for (const stateMappingKey of stateMappingKeys) { |
| 606 | + const subscriber = callbackToStateMapping[stateMappingKey]; |
607 | 607 | if (!subscriber) { |
608 | 608 | continue; |
609 | 609 | } |
@@ -640,9 +640,7 @@ function keysChanged<TKey extends CollectionKeyBase>( |
640 | 640 | // If they are not using waitForCollectionCallback then we notify the subscriber with |
641 | 641 | // the new merged data but only for any keys in the partial collection. |
642 | 642 | const dataKeys = Object.keys(partialCollection ?? {}); |
643 | | - for (let j = 0; j < dataKeys.length; j++) { |
644 | | - const dataKey = dataKeys[j]; |
645 | | - |
| 643 | + for (const dataKey of dataKeys) { |
646 | 644 | if (deepEqual(cachedCollection[dataKey], previousCollection[dataKey])) { |
647 | 645 | continue; |
648 | 646 | } |
@@ -699,8 +697,7 @@ function keysChanged<TKey extends CollectionKeyBase>( |
699 | 697 | const prevCollection = prevState?.[subscriber.statePropertyName] ?? {}; |
700 | 698 | const finalCollection = lodashClone(prevCollection); |
701 | 699 | const dataKeys = Object.keys(partialCollection ?? {}); |
702 | | - for (let j = 0; j < dataKeys.length; j++) { |
703 | | - const dataKey = dataKeys[j]; |
| 700 | + for (const dataKey of dataKeys) { |
704 | 701 | finalCollection[dataKey] = cachedCollection[dataKey]; |
705 | 702 | } |
706 | 703 |
|
@@ -819,8 +816,8 @@ function keyChanged<TKey extends OnyxKey>( |
819 | 816 |
|
820 | 817 | const cachedCollections: Record<string, ReturnType<typeof getCachedCollection>> = {}; |
821 | 818 |
|
822 | | - for (let i = 0; i < stateMappingKeys.length; i++) { |
823 | | - const subscriber = callbackToStateMapping[stateMappingKeys[i]]; |
| 819 | + for (const stateMappingKey of stateMappingKeys) { |
| 820 | + const subscriber = callbackToStateMapping[stateMappingKey]; |
824 | 821 | if (!subscriber || !isKeyMatch(subscriber.key, key) || !canUpdateSubscriber(subscriber)) { |
825 | 822 | continue; |
826 | 823 | } |
@@ -1287,7 +1284,7 @@ function subscribeToKey<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKe |
1287 | 1284 | // Performance improvement |
1288 | 1285 | // If the mapping is connected to an onyx key that is not a collection |
1289 | 1286 | // we can skip the call to getAllKeys() and return an array with a single item |
1290 | | - if (Boolean(mapping.key) && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && cache.getAllKeys().has(mapping.key)) { |
| 1287 | + if (!!mapping.key && typeof mapping.key === 'string' && !isCollectionKey(mapping.key) && cache.getAllKeys().has(mapping.key)) { |
1291 | 1288 | return new Set([mapping.key]); |
1292 | 1289 | } |
1293 | 1290 | return getAllKeys(); |
|
0 commit comments