Skip to content

Commit

Permalink
IGListBindingSectionController no longer asserts when reloading the e…
Browse files Browse the repository at this point in the history
…ntire section. (Instagram#1213)

Summary:
Issue fixed: Instagram#1174

- [X] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [X] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [X] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Pull Request resolved: Instagram#1213

Differential Revision: D9003398

Pulled By: rnystrom

fbshipit-source-id: 2c68f42e21abaea9191f26309668d866544f80b4
  • Loading branch information
jeffbailey authored and larssondaniel committed Nov 16, 2019
1 parent cce5a46 commit 45dde1f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

4.0.0 (upcoming release)
-----
### Breaking Changes

- All `IGListBindingSectionControllerSelectionDelegate` methods are now required. [Bofei Zhu] (https://github.com/zhubofei) [(#1186)](https://github.com/Instagram/IGListKit/pull/1186)

### Enhancements

- Added `IGListCollectionScrollingTraits` for exposing `UICollectionView` scrolling traits to section controllers via `IGListCollectionContext`. [Adam Stern](https://github.com/adamastern) (tbd)

- `IGListBindingSectionController` no longer asserts when reloading the entire section. A warning message is now logged if the entire section is going to be reloaded. [Jeff Bailey](https://github.com/jeffbailey) (#1213)

### Fixes

- Experimental fix to get the `UICollectionView` for batch updating immediately before applying the update. [Ryan Nystrom](https://github.com/rnystrom) (tbd)

- `[IGListAdapterUpdater performBatchUpdatesWithCollectionViewBlock:]` and `[IGListAdapterUpdater performReloadDataWithCollectionViewBlock:]` clean state and run completion blocks if their `UICollectionView` is nil. [Brandon Darin](https://github.com/jbd1030) (tbd)

- Ensuring view models with duplicate diff identifiers are removed when view models are first requested by `IGListBindingSectionController` [Adam Stern](https://github.com/adamastern) (tbd)

- Fixed `[IGListAdapterUpdater reloadItemInCollectionView:fromIndexPath:toIndexPath:]` does not call delegate when not inside a batch update. [Bofei Zhu] (https://github.com/zhubofei) [(#1211)](https://github.com/Instagram/IGListKit/pull/1211)

- Log instead of assert for duplicate diff identifiers to make code testable. [Adam Stern](https://github.com/adamastern) (tbd)

3.4.0
-----
Expand Down
9 changes: 6 additions & 3 deletions Source/IGListBindingSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ - (void)didUpdateToObject:(id)object {
if (oldObject == nil) {
self.viewModels = [[self.dataSource sectionController:self viewModelsForObject:object] copy];
} else {
IGAssert([oldObject isEqualToDiffableObject:object],
@"Unequal objects %@ and %@ will cause IGListBindingSectionController to reload the entire section",
oldObject, object);
#if IGLK_LOGGING_ENABLED
if (![oldObject isEqualToDiffableObject:object]) {
IGLKLog(@"Warning: Unequal objects %@ and %@ will cause IGListBindingSectionController to reload the entire section",
oldObject, object);
}
#endif
[self updateAnimated:YES completion:nil];
}
}
Expand Down
14 changes: 12 additions & 2 deletions Tests/Objects/IGTestDiffingObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ - (NSString *)description {
return self.key;
}

- (BOOL)isEqualToDiffableObject:(id<IGListDiffable>)object {
return YES;
- (BOOL)isEqualToDiffableObject:(id)object {
if (object == self) {
return YES;
}
if ([object isKindOfClass:[IGTestDiffingObject class]]) {
/* A simple equality test that only looks at the number of objects for the key.
It does not currently test the equality of each of the objects. */
IGTestDiffingObject *testDiffingObject = (IGTestDiffingObject *)object;
return self.objects.count == testDiffingObject.objects.count;
}

return NO;
}

@end

0 comments on commit 45dde1f

Please sign in to comment.