mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
[WIP] Trigger new batch fetch for collection view after layout transitions (#1697)
[Table / Collection] Trigger new batch fetch after programmatic scrolls, or layout transitions.
This commit is contained in:
@@ -1002,6 +1002,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
- (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeController
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
// Calling visibleNodeIndexPathsForRangeController: will trigger UIKit to call reloadData if it never has, which can result
|
||||
// in incorrect layout if performed at zero size. We can use the fact that nothing can be visible at zero size to return fast.
|
||||
BOOL isZeroSized = CGRectEqualToRect(self.bounds, CGRectZero);
|
||||
@@ -1065,6 +1066,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
_performingBatchUpdates = NO;
|
||||
}
|
||||
|
||||
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
|
||||
{
|
||||
[self _checkForBatchFetching];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -968,6 +968,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
|
||||
{
|
||||
[self _checkForBatchFetching];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -146,6 +146,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController * )rangeController didEndUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion;
|
||||
|
||||
/**
|
||||
* Completed updates to cell node addition and removal.
|
||||
*
|
||||
* @param rangeController Sender.
|
||||
*/
|
||||
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController;
|
||||
|
||||
/**
|
||||
* Called for nodes insertion.
|
||||
*
|
||||
|
||||
@@ -333,6 +333,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
||||
[modifiedIndexPaths sortUsingSelector:@selector(compare:)];
|
||||
NSLog(@"Range update complete; modifiedIndexPaths: %@", [self descriptionWithIndexPaths:modifiedIndexPaths]);
|
||||
#endif
|
||||
[_delegate didCompleteUpdatesInRangeController:self];
|
||||
}
|
||||
|
||||
#pragma mark - Notification observers
|
||||
|
||||
Reference in New Issue
Block a user