mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 09:18:29 +00:00
Fix for #348 - IGListStackedSectionController's children need to know numberOrItems before didUpdate is called
Summary: The reloadData method in IGListStackedSectionController was being called too soon. It was moved from the constructor to the `didUpdateToObject` method. Tests were updated to reflect the change. - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [ ] 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) Closes https://github.com/Instagram/IGListKit/pull/390 Differential Revision: D4419751 Pulled By: rnystrom fbshipit-source-id: 7c812d306b23dd251c160425873930eb8022b1a5
This commit is contained in:
parent
16be9474d2
commit
8d74b8f778
4 changed files with 12 additions and 5 deletions
|
|
@ -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
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ static void * kStackedSectionControllerIndexKey = &kStackedSectionControllerInde
|
|||
self.displayDelegate = self;
|
||||
self.scrollDelegate = self;
|
||||
self.workingRangeDelegate = self;
|
||||
|
||||
[self reloadData];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -152,6 +150,7 @@ static void * kStackedSectionControllerIndexKey = &kStackedSectionControllerInde
|
|||
for (IGListSectionController<IGListSectionType> *sectionController in self.sectionControllers) {
|
||||
[sectionController didUpdateToObject:object];
|
||||
}
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
- (void)didSelectItemAtIndex:(NSInteger)index {
|
||||
|
|
|
|||
|
|
@ -35,5 +35,6 @@ IGListWorkingRangeDelegate
|
|||
|
||||
- (IGListSectionController <IGListSectionType> *)sectionControllerForObjectIndex:(NSInteger)itemIndex;
|
||||
- (NSInteger)offsetForSectionController:(IGListSectionController<IGListSectionType> *)sectionController;
|
||||
- (void)reloadData;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
section4.items = 1;
|
||||
|
||||
IGListStackedSectionController *stack = [[IGListStackedSectionController alloc] initWithSectionControllers:@[section1, section2, section3, section4]];
|
||||
|
||||
[stack reloadData];
|
||||
|
||||
XCTAssertEqual([stack numberOfItems], 6);
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +101,8 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
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);
|
||||
|
|
@ -120,6 +122,8 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
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);
|
||||
|
|
@ -307,10 +311,11 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
|
||||
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];
|
||||
}
|
||||
|
|
@ -329,6 +334,7 @@ static const CGRect kStackTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
|||
|
||||
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]];
|
||||
|
|
|
|||
Loading…
Reference in a new issue