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

Fix for #348 - IGListStackedSectionController's children need to know numberOrItems before didUpdate is called #390

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This release closes the [2.2.0 milestone](https://github.com/Instagram/IGListKit
### Fixes

- 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)

2.1.0
-----
Expand Down
3 changes: 1 addition & 2 deletions Source/IGListStackedSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ - (instancetype)initWithSectionControllers:(NSArray <IGListSectionController<IGL
self.displayDelegate = self;
self.scrollDelegate = self;
self.workingRangeDelegate = self;

[self reloadData];
}
return self;
}
Expand Down Expand Up @@ -152,6 +150,7 @@ - (void)didUpdateToObject:(id)object {
for (IGListSectionController<IGListSectionType> *sectionController in self.sectionControllers) {
[sectionController didUpdateToObject:object];
}
[self reloadData];
}

- (void)didSelectItemAtIndex:(NSInteger)index {
Expand Down
1 change: 1 addition & 0 deletions Source/Internal/IGListStackedSectionControllerInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ IGListWorkingRangeDelegate

- (IGListSectionController <IGListSectionType> *)sectionControllerForObjectIndex:(NSInteger)itemIndex;
- (NSInteger)offsetForSectionController:(IGListSectionController<IGListSectionType> *)sectionController;
- (void)reloadData;

@end
12 changes: 9 additions & 3 deletions Tests/IGListStackSectionControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ - (void)test_whenInitializingStack_thatNumberOfItemsMatches {
section4.items = 1;

IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2, section3, section4]];

[stack reloadData];

XCTAssertEqual([stack numberOfItems], 6);
}

Expand All @@ -100,7 +101,8 @@ - (void)test_whenInitializingStack_thatSectionControllerIndexesMatch {
section4.items = 1;

IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2, section3, section4]];

[stack reloadData];

XCTAssertEqualObjects([stack sectionControllerForObjectIndex:0], section1);
XCTAssertEqualObjects([stack sectionControllerForObjectIndex:1], section1);
XCTAssertEqualObjects([stack sectionControllerForObjectIndex:2], section2);
Expand All @@ -120,6 +122,8 @@ - (void)test_whenInitializingStack_thatSectionControllerOffsetsMatch {
section4.items = 1;

IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2, section3, section4]];
[stack reloadData];

XCTAssertEqual([stack offsetForSectionController:section1], 0);
XCTAssertEqual([stack offsetForSectionController:section2], 2);
XCTAssertEqual([stack offsetForSectionController:section3], 5);
Expand Down Expand Up @@ -307,10 +311,11 @@ - (void)test_whenDisplayingCell_thatEventsForwardedToSectionControllers {

IGListDisplayHandler *display = [[IGListDisplayHandler alloc] init];
IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2]];
[stack reloadData];

[display willDisplayCell:cell1 forListAdapter:self.adapter sectionController:stack object:@"a" indexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
[display willDisplayCell:cell2 forListAdapter:self.adapter sectionController:stack object:@"a" indexPath:[NSIndexPath indexPathForItem:1 inSection:0]];

[mock1Delegate verify];
[mock2Delegate verify];
}
Expand All @@ -329,6 +334,7 @@ - (void)test_whenEndDisplayingCell_thatEventsForwardedToSectionControllers {

IGListDisplayHandler *display = [[IGListDisplayHandler alloc] init];
IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2]];
[stack reloadData];

// display all 4 cells (2 per child section controller)
[display willDisplayCell:cell1 forListAdapter:self.adapter sectionController:stack object:@"a" indexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
Expand Down