From a511891376b75e195942a08241e2a2c0c046cbe0 Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Wed, 11 Oct 2023 22:30:36 -0700 Subject: [PATCH] Refactored check in IGListCollectionViewLayout for more reliable coverage Summary: The `[context invalidateDataSourceCounts] && _minimumInvalidatedSection == NSNotFound` condition was never getting triggered in any of our tests. I tried to simulate this condition in my testing, but it doesn't seem possible to have `_minimumInvalidatedSection` set to `NSNotFound` when execution reaches this point. This is because the only public pathway I could see to `[context invalidateLayoutWithContext:]` was via the regular `invalidateLayout` method which always sets `_minimumInvalidatedSection` to 0 before continuing. To solve this, since the resulting logic ends up being the same in the check above, I simply collapsed this check into the one above it. Reviewed By: fabiomassimo Differential Revision: D50000788 fbshipit-source-id: da0bf0cb16c98de95f802dfd35bbdf0e935e615f --- Source/IGListKit/IGListCollectionViewLayout.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/IGListKit/IGListCollectionViewLayout.mm b/Source/IGListKit/IGListCollectionViewLayout.mm index 534f60025..98d30279a 100644 --- a/Source/IGListKit/IGListCollectionViewLayout.mm +++ b/Source/IGListKit/IGListCollectionViewLayout.mm @@ -389,12 +389,10 @@ - (void)invalidateLayoutWithContext:(IGListCollectionViewLayoutInvalidationConte if (hasInvalidatedItemIndexPaths || [context invalidateEverything] + || ([context invalidateDataSourceCounts] && _minimumInvalidatedSection == NSNotFound) // if count changed and we don't have information on the minimum invalidated section || context.ig_invalidateAllAttributes) { // invalidates all _minimumInvalidatedSection = 0; - } else if ([context invalidateDataSourceCounts] && _minimumInvalidatedSection == NSNotFound) { - // invalidate all if count changed and we don't have information on the minimum invalidated section - _minimumInvalidatedSection = 0; } if (context.ig_invalidateSupplementaryAttributes) {