mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix fetching will continually trigger in a loop after reaching end of content
Don't schedule a new check for a batch fetch if no data changed previous batch fetch
This commit is contained in:
@@ -730,8 +730,13 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_scheduleCheckForBatchFetching
|
||||
- (void)_scheduleCheckForBatchFetchingForNumberOfChanges:(NSUInteger)changes
|
||||
{
|
||||
// Prevent fetching will continually trigger in a loop after reaching end of content and no new content was provided
|
||||
if (changes == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Push this to the next runloop to be sure the scroll view has the right content size
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _checkForBatchFetching];
|
||||
@@ -904,7 +909,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
BOOL preventAnimation = animationOptions == UITableViewRowAnimationNone;
|
||||
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOptions];
|
||||
[self _scheduleCheckForBatchFetching];
|
||||
[self _scheduleCheckForBatchFetchingForNumberOfChanges:indexPaths.count];
|
||||
});
|
||||
|
||||
if (_automaticallyAdjustsContentOffset) {
|
||||
@@ -924,7 +929,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
BOOL preventAnimation = animationOptions == UITableViewRowAnimationNone;
|
||||
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOptions];
|
||||
[self _scheduleCheckForBatchFetching];
|
||||
[self _scheduleCheckForBatchFetchingForNumberOfChanges:indexPaths.count];
|
||||
});
|
||||
|
||||
if (_automaticallyAdjustsContentOffset) {
|
||||
@@ -945,7 +950,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
BOOL preventAnimation = animationOptions == UITableViewRowAnimationNone;
|
||||
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOptions];
|
||||
[self _scheduleCheckForBatchFetching];
|
||||
[self _scheduleCheckForBatchFetchingForNumberOfChanges:indexSet.count];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -961,7 +966,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
BOOL preventAnimation = animationOptions == UITableViewRowAnimationNone;
|
||||
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOptions];
|
||||
[self _scheduleCheckForBatchFetching];
|
||||
[self _scheduleCheckForBatchFetchingForNumberOfChanges:indexSet.count];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user