Skip to content

Commit

Permalink
clean up IGListExperimentGetCollectionViewAtUpdate
Browse files Browse the repository at this point in the history
Summary: Experiment shipped.

Reviewed By: Haud, lorixx

Differential Revision: D22219242

fbshipit-source-id: 60dbb5f008656ae67b02294ef16138703ebe392f
  • Loading branch information
maxolls authored and facebook-github-bot committed Jun 26, 2020
1 parent a70d2d7 commit 34c935c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

- Fixed missing update when calling `performUpdatesAnimated` multiple times quickly and using the `reloadDataFallback()`. [Maxime Ollivier](https://github.com/maxolls) (tbd)

- Request the `UICollectionView` until just-before we update. This way if the `UICollectionView` is changed between update-queue and execution, we guarantee the update is performed on the correct view. Ship with experiment `IGListExperimentGetCollectionViewAtUpdate` from Ryan Nystrom. [Maxime Ollivier](https://github.com/maxolls) (tbd)

4.0.0
-----
### Breaking Changes
Expand Down
4 changes: 1 addition & 3 deletions Source/IGListDiffKit/IGListExperiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentReloadDataFallback = 1 << 3,
/// Test deferring object creation until just before diffing.
IGListExperimentDeferredToObjectCreation = 1 << 4,
/// Test getting collection view at update time.
IGListExperimentGetCollectionViewAtUpdate = 1 << 5,
/// Test invalidating layout when cell reloads/updates in IGListBindingSectionController.
IGListExperimentInvalidateLayoutForUpdates = 1 << 6,
IGListExperimentInvalidateLayoutForUpdates = 1 << 5,
};

/**
Expand Down
12 changes: 3 additions & 9 deletions Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ - (void)setCollectionView:(UICollectionView *)collectionView {
[self _updateCollectionViewDelegate];

// only construct
if (!IGListExperimentEnabled(self.experiments, IGListExperimentGetCollectionViewAtUpdate)
|| settingFirstCollectionView) {
if (settingFirstCollectionView) {
[self _updateAfterPublicSettingsChange];
}
}
Expand Down Expand Up @@ -573,13 +572,8 @@ - (CGSize)sizeForSupplementaryViewOfKind:(NSString *)elementKind atIndexPath:(NS
#pragma mark - Private API

- (IGListCollectionViewBlock)_collectionViewBlock {
if (IGListExperimentEnabled(self.experiments, IGListExperimentGetCollectionViewAtUpdate)) {
__weak __typeof__(self) weakSelf = self;
return ^UICollectionView *{ return weakSelf.collectionView; };
} else {
__weak UICollectionView *collectionView = _collectionView;
return ^UICollectionView *{ return collectionView; };
}
__weak __typeof__(self) weakSelf = self;
return ^UICollectionView *{ return weakSelf.collectionView; };
}

// this method is what updates the "source of truth"
Expand Down
4 changes: 0 additions & 4 deletions Tests/IGListAdapterE2ETests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,6 @@ - (void)test_whenModifyingInitialAndFinalAttribute_thatLayoutIsCorrect {
- (void)test_whenSwappingCollectionViewsAfterUpdate_thatUpdatePerformedOnTheCorrectCollectionView {
// BEGIN: setup of FIRST adapter+dataSource+collectionView
IGListAdapter *adapter1 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil];
adapter1.experiments |= IGListExperimentGetCollectionViewAtUpdate;

UICollectionView *collectionView1 = [[UICollectionView alloc] initWithFrame:self.window.frame collectionViewLayout:[UICollectionViewFlowLayout new]];
[self.window addSubview:collectionView1];
Expand All @@ -1857,7 +1856,6 @@ - (void)test_whenSwappingCollectionViewsAfterUpdate_thatUpdatePerformedOnTheCorr

// BEGIN: setup of SECOND adapter+dataSource+collectionView
IGListAdapter *adapter2 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil];
adapter2.experiments |= IGListExperimentGetCollectionViewAtUpdate;

UICollectionView *collectionView2 = [[UICollectionView alloc] initWithFrame:self.window.frame collectionViewLayout:[UICollectionViewFlowLayout new]];
[self.window addSubview:collectionView2];
Expand Down Expand Up @@ -1891,7 +1889,6 @@ - (void)test_whenCollectionViewBecomesNilDuringPerformUpdates_thatStateCleanedCo
[self setupWithObjects:@[
genTestObject(@1, @1)
]];
self.adapter.experiments |= IGListExperimentGetCollectionViewAtUpdate;

// perform update on listAdapter
XCTestExpectation *expectation1 = genExpectation;
Expand Down Expand Up @@ -1938,7 +1935,6 @@ - (void)test_whenCollectionViewBecomesNilDuringReloadData_thatStateCleanedCorrec
[self setupWithObjects:@[
genTestObject(@1, @1)
]];
self.adapter.experiments |= IGListExperimentGetCollectionViewAtUpdate;

// reload data on listAdapter
XCTestExpectation *expectation1 = genExpectation;
Expand Down

0 comments on commit 34c935c

Please # to comment.