rename movesAsDeletesInserts to sectionMovesAsDeletesInserts

Summary: Lets clarify that we're taking about section moves

Reviewed By: Haud

Differential Revision: D22897102

fbshipit-source-id: ea77ef695ddae8e7b1df96d51002bc8c0cc7fab7
This commit is contained in:
Maxime Ollivier 2020-08-03 07:17:41 -07:00 committed by Facebook GitHub Bot
parent 158eb4b04c
commit af78523453
6 changed files with 20 additions and 12 deletions

View file

@ -32,16 +32,21 @@ NS_SWIFT_NAME(ListAdapterUpdater)
@property (nonatomic, weak) id<IGListAdapterUpdaterDelegate> delegate;
/**
A flag indicating if a move should be treated as a "delete, then insert" operation.
A flag indicating if a section move should be treated as a section "delete, then insert" operation. This can be useful if you're
performing a lot of updates and moves are too distracting.
Default is NO.
*/
@property (nonatomic, assign) BOOL movesAsDeletesInserts;
@property (nonatomic, assign) BOOL sectionMovesAsDeletesInserts;
/**
ONLY used when there is N section, but each section only contains 1 item.
We don't need to change move into delete+insert, and we dont need to call -reload at all.
This unlocks many default UICollectionView animations: move/inline cell updates/deletes/inserts etc.
Default is NO.
@warning This should only work for Section that *ONLY* has single item setup.
*/
@property (nonatomic, assign) BOOL singleItemSectionUpdates;
@ -50,10 +55,10 @@ NS_SWIFT_NAME(ListAdapterUpdater)
A flag indicating that section reloads should be treated as item reloads, instead of converting them to "delete, then insert" operations.
This only applies if the number of items for the section is unchanged.
Default is NO.
@note If the number of items for the section is changed, we would fallback to the default behavior and convert it to "delete + insert",
because the collectionView can crash otherwise.
Default is NO.
*/
@property (nonatomic, assign) BOOL preferItemReloadsForSectionReloads;
@ -61,6 +66,8 @@ NS_SWIFT_NAME(ListAdapterUpdater)
A flag indicating whether this updater should skip diffing and simply call
`reloadData` for updates when the collection view is not in a window. The default value is `YES`.
Default is YES.
@note This will result in better performance, but will not generate the same delegate
callbacks. If using a custom layout, it will not receive `prepareForCollectionViewUpdates:`.
@ -70,6 +77,7 @@ NS_SWIFT_NAME(ListAdapterUpdater)
/**
If there's more than 100 diff updates, fallback to using `reloadData` to avoid stalling the main thread.
Default is YES.
*/
@property (nonatomic, assign) BOOL allowsReloadingOnTooManyUpdates;

View file

@ -227,7 +227,7 @@ typedef void (^IGListAdapterUpdaterCompletionBlock)(BOOL);
self.batchUpdates,
fromObjects,
experiments,
self.movesAsDeletesInserts,
self.sectionMovesAsDeletesInserts,
self.preferItemReloadsForSectionReloads);
}

View file

@ -27,7 +27,7 @@ static NSMutableArray *linesFromObjects(NSArray *objects) {
- (NSArray<NSString *> *)debugDescriptionLines {
NSMutableArray *debug = [NSMutableArray new];
#if defined(IGLK_DEBUG_DESCRIPTION_ENABLED) && IGLK_DEBUG_DESCRIPTION_ENABLED
[debug addObject:[NSString stringWithFormat:@"Moves as deletes+inserts: %@", IGListDebugBOOL(self.movesAsDeletesInserts)]];
[debug addObject:[NSString stringWithFormat:@"Section moves as deletes+inserts: %@", IGListDebugBOOL(self.sectionMovesAsDeletesInserts)]];
[debug addObject:[NSString stringWithFormat:@"Allows background reloading: %@", IGListDebugBOOL(self.allowsBackgroundReloading)]];
[debug addObject:[NSString stringWithFormat:@"Has queued reload data: %@", IGListDebugBOOL(self.hasQueuedReloadData)]];
[debug addObject:[NSString stringWithFormat:@"Queued update is animated: %@", IGListDebugBOOL(self.queuedUpdateIsAnimated)]];

View file

@ -27,7 +27,7 @@ IGListBatchUpdateData *IGListApplyUpdatesToCollectionView(UICollectionView *coll
IGListBatchUpdates *batchUpdates,
NSArray<id<IGListDiffable>> *fromObjects,
IGListExperiment experiments,
BOOL movesAsDeletesInserts,
BOOL sectionMovesAsDeletesInserts,
BOOL preferItemReloadsForSectionReloads);
NS_ASSUME_NONNULL_END

View file

@ -59,7 +59,7 @@ IGListBatchUpdateData *IGListApplyUpdatesToCollectionView(UICollectionView *coll
IGListBatchUpdates *batchUpdates,
NSArray<id<IGListDiffable>> *fromObjects,
IGListExperiment experiments,
BOOL movesAsDeletesInserts,
BOOL sectionMovesAsDeletesInserts,
BOOL preferItemReloadsForSectionReloads) {
NSSet *moves = [[NSSet alloc] initWithArray:diffResult.moves];
@ -70,7 +70,7 @@ IGListBatchUpdateData *IGListApplyUpdatesToCollectionView(UICollectionView *coll
NSMutableIndexSet *inserts = [diffResult.inserts mutableCopy];
NSMutableIndexSet *deletes = [diffResult.deletes mutableCopy];
NSMutableArray<NSIndexPath *> *itemUpdates = [NSMutableArray new];
if (movesAsDeletesInserts) {
if (sectionMovesAsDeletesInserts) {
for (IGListMoveIndex *move in moves) {
[deletes addIndex:move.from];
[inserts addIndex:move.to];

View file

@ -377,7 +377,7 @@
[self.updater performReloadDataWithCollectionViewBlock:[self collectionViewBlock]];
// without moves as inserts, we would assert b/c the # of items in each section changes
self.updater.movesAsDeletesInserts = YES;
self.updater.sectionMovesAsDeletesInserts = YES;
XCTestExpectation *expectation = genExpectation;
[self.updater performUpdateWithCollectionViewBlock:[self collectionViewBlock] fromObjects:from toObjectsBlock:to animated:YES objectTransitionBlock:self.updateBlock completion:^(BOOL finished) {