Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowsBackgroundReloading Flag to ListAdapterUpdater to Give User Control of Behavior #375

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion Source/IGListAdapterUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ - (void)performBatchUpdatesWithCollectionView:(UICollectionView *)collectionView
// if the collection view isn't in a visible window, skip diffing and batch updating. execute all transition blocks,
// reload data, execute completion blocks, and get outta here
BOOL iOS83OrLater = (NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_8_3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can keep this in here for now, but IMO better to keep PRs changing one thing at a time. Makes crawling history and blames a lot easier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this const BOOL too 😊

if (iOS83OrLater && _skipsDiffingWhenOffscreen && collectionView.window == nil) {
if (iOS83OrLater && self.skipsDiffingWhenOffscreen && collectionView.window == nil) {
[self beginPerformBatchUpdatestoObjects:toObjects];
executeUpdateBlocks();
[self cleanupUpdateBlockState];
Expand Down
6 changes: 2 additions & 4 deletions Tests/IGListAdapterUpdaterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ - (void)test_whenCallingReloadData_withUICollectionViewFlowLayout_withEstimatedS
XCTAssertEqual([collectionView numberOfItemsInSection:1], 4);
}

- (void)test_whenCollectionViewNotInWindow_andDiffSkippingFlagSetNO_diffHappens
{
- (void)test_whenCollectionViewNotInWindow_andDiffSkippingFlagSetNO_diffHappens {
self.updater.skipsDiffingWhenOffscreen = NO;
[self.collectionView removeFromSuperview];

Expand All @@ -481,8 +480,7 @@ - (void)test_whenCollectionViewNotInWindow_andDiffSkippingFlagSetNO_diffHappens
[mockDelegate verify];
}

- (void)test_whenCollectionViewNotInWindow_andDiffSkippingFlagDefaultYES_diffDoesNotHappen
{
- (void)test_whenCollectionViewNotInWindow_andDiffSkippingFlagDefaultYES_diffDoesNotHappen {
[self.collectionView removeFromSuperview];

id mockDelegate = [OCMockObject niceMockForProtocol:@protocol(IGListAdapterUpdaterDelegate)];
Expand Down