mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-22 08:48:21 +00:00
Add missed delegate call #trivial (#1211)
Summary: Issue fixed: # - [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: https://github.com/Instagram/IGListKit/pull/1211 Differential Revision: D9003392 Pulled By: rnystrom fbshipit-source-id: 73ef837300f8fdb6d9a6005e86f8e9e842827979
This commit is contained in:
parent
f6714308db
commit
67da3b4f5f
3 changed files with 43 additions and 1 deletions
|
|
@ -16,11 +16,12 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
|
|||
|
||||
- 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
|
||||
|
|
|
|||
|
|
@ -534,6 +534,7 @@ static NSUInteger IGListIdentifierHash(const void *item, NSUInteger (*size)(cons
|
|||
IGListReloadIndexPath *reload = [[IGListReloadIndexPath alloc] initWithFromIndexPath:fromIndexPath toIndexPath:toIndexPath];
|
||||
[self.batchUpdates.itemReloads addObject:reload];
|
||||
} else {
|
||||
[self.delegate listAdapterUpdater:self willReloadIndexPaths:@[fromIndexPath] collectionView:collectionView];
|
||||
[collectionView reloadItemsAtIndexPaths:@[fromIndexPath]];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -602,6 +602,46 @@
|
|||
[self waitForExpectationsWithTimeout:30 handler:nil];
|
||||
}
|
||||
|
||||
- (void)test_whenNotBatchUpdate_thatDelegateEventsSent {
|
||||
IGSectionObject *object = [IGSectionObject sectionWithObjects:@[@0, @1, @2]];
|
||||
self.dataSource.sections = @[object];
|
||||
[self.collectionView reloadData];
|
||||
|
||||
id mockDelegate = [OCMockObject niceMockForProtocol:@protocol(IGListAdapterUpdaterDelegate)];
|
||||
self.updater.delegate = mockDelegate;
|
||||
[mockDelegate setExpectationOrderMatters:YES];
|
||||
[[mockDelegate expect] listAdapterUpdater:self.updater willDeleteIndexPaths:OCMOCK_ANY collectionView:self.collectionView];
|
||||
[[mockDelegate expect] listAdapterUpdater:self.updater willInsertIndexPaths:OCMOCK_ANY collectionView:self.collectionView];
|
||||
[[mockDelegate expect] listAdapterUpdater:self.updater
|
||||
willMoveFromIndexPath:OCMOCK_ANY
|
||||
toIndexPath:OCMOCK_ANY
|
||||
collectionView:self.collectionView];
|
||||
[[mockDelegate expect] listAdapterUpdater:self.updater willReloadIndexPaths:OCMOCK_ANY collectionView:self.collectionView];
|
||||
|
||||
// This code is of no use, but it will let UICollectionView synchronize number of items,
|
||||
// so it will not crash in following updates. https://stackoverflow.com/a/46751421/2977647
|
||||
[self.collectionView numberOfItemsInSection:0];
|
||||
|
||||
object.objects = @[@1, @2];
|
||||
[self.updater deleteItemsFromCollectionView:self.collectionView indexPaths:@[
|
||||
[NSIndexPath indexPathForItem:0 inSection:0],
|
||||
]];
|
||||
object.objects = @[@1, @2, @4, @5];
|
||||
[self.updater insertItemsIntoCollectionView:self.collectionView indexPaths:@[
|
||||
[NSIndexPath indexPathForItem:2 inSection:0],
|
||||
[NSIndexPath indexPathForItem:3 inSection:0],
|
||||
]];
|
||||
object.objects = @[@2, @1, @4, @5];
|
||||
[self.updater moveItemInCollectionView:self.collectionView
|
||||
fromIndexPath:[NSIndexPath indexPathForItem:2 inSection:0]
|
||||
toIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
|
||||
|
||||
[self.updater reloadItemInCollectionView:self.collectionView
|
||||
fromIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]
|
||||
toIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
|
||||
[mockDelegate verify];
|
||||
}
|
||||
|
||||
- (void)test_whenObjectIdentifiersCollide_withDifferentTypes_thatLookupReturnsNil {
|
||||
id testObject = [[IGTestObject alloc] initWithKey:@"foo" value:@"bar"];
|
||||
id collision = @"foo";
|
||||
|
|
|
|||
Loading…
Reference in a new issue