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

IGListBindingSectionController no longer asserts when reloading the entire section. #1213

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
70adbca
Fix for issue #294 - Support for UIAppearance in IGListCollectionView…
jeffbailey Dec 7, 2016
85cfec0
Issue #299: Unit tests for IGListCollectionView
jeffbailey Dec 8, 2016
c9cff83
Merge remote-tracking branch 'upstream/master'
jeffbailey Dec 8, 2016
651a992
Combine IGListCollectionView test files. Tests are now more localize…
jeffbailey Dec 9, 2016
f25b20e
Merge remote-tracking branch 'upstream/master'
jeffbailey Dec 11, 2016
55a8211
Merge remote-tracking branch 'upstream/master'
jeffbailey Dec 23, 2016
c0aba3d
Merge remote-tracking branch 'upstream/master'
jeffbailey Jan 6, 2017
1d4de97
Fix for #348 - IGListStackedSectionController's children need to know…
jeffbailey Jan 6, 2017
43d43a4
Merge branch 'master' into master
rnystrom Jan 10, 2017
c8566f2
Merge remote-tracking branch 'upstream/master'
jeffbailey Jan 11, 2017
2ec527c
Merge branch 'master' of https://github.com/jeffbailey/IGListKit
jeffbailey Jan 11, 2017
fbfebf9
Fix for #348: Updated unit tests for IGListStackSectionController
jeffbailey Jan 11, 2017
e0e7031
Merge branch 'master' into master
jeffbailey Jan 13, 2017
447aa0c
Fix for #348: Update CHANGELOG
jeffbailey Jan 13, 2017
8c5bd9e
Merge branch 'master' of https://github.com/jeffbailey/IGListKit
jeffbailey Jan 13, 2017
15f9015
Merge branch 'master' of https://github.com/Instagram/IGListKit
jeffbailey Jul 9, 2018
14c8f46
Support reloading a IGListBindingSectionController. #1174
jeffbailey Jul 10, 2018
9b226ac
More descriptive change log for #1213.
jeffbailey Jul 14, 2018
eb0853f
Reworded change log for #1213.
jeffbailey Jul 14, 2018
5f29faf
undo changelog entry
rnystrom Jul 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

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

- Support reloading a `IGListBindingSectionController`. [Jeff Bailey](https://github.com/jeffbailey) (tbd)
Copy link
Contributor

Choose a reason for hiding this comment

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

2 nits:

  • Replace tbd with the number and link to this PR (1213)
  • Let's make the line a little more descriptive. Something like "no longer asserts when reloading..." etc etc.


### Fixes

- Experimental fix to get the `UICollectionView` for batch updating immediately before applying the update. [Ryan Nystrom](https://github.com/rnystrom) (tbd)
Expand Down Expand Up @@ -236,6 +238,7 @@ ListDiff(oldArray: [], newArray: [], .equality)
- Gracefully handle a `nil` section controller returned by an `IGListAdapterDataSource`. [Ryan Nystrom](https://github.com/rnystrom) [(#488)](https://github.com/Instagram/IGListKit/pull/488)

- Fix bug where emptyView's hidden status is not updated after the number of items is changed with `insertInSectionController:atIndexes:` or related methods. [Peter Edmonston](https://github.com/edmonston) [(#395)](https://github.com/Instagram/IGListKit/pull/395)
- Fix bug where `IGListStackedSectionController`'s children need to know `numberOrItems` before didUpdate is called. [(#348)](https://github.com/Instagram/IGListKit/pull/390)

- Fix bug where `IGListStackedSectionController`'s children need to know `numberOrItems` before didUpdate is called. [(#348)](https://github.com/Instagram/IGListKit/pull/390)

Expand Down
9 changes: 6 additions & 3 deletions Source/IGListBindingSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ - (void)didUpdateToObject:(id)object {
NSArray *viewModels = [self.dataSource sectionController:self viewModelsForObject:object];
self.viewModels = objectsWithDuplicateIdentifiersRemoved(viewModels);
} 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Noting to myself that this actually tests not tripping the assert anymore. See comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Pull request has been updated @rnystrom.

}

@end