mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 03:21:29 +00:00
Revert to using a single NSIndexPath for the pending visible item
This commit is contained in:
parent
8bdcbe1be0
commit
0e37bff7c1
@ -125,7 +125,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
|
||||
ASBatchContext *_batchContext;
|
||||
|
||||
NSMutableSet *_pendingVisibleIndexPaths;
|
||||
NSIndexPath *_pendingVisibleIndexPath;
|
||||
}
|
||||
|
||||
@property (atomic, assign) BOOL asyncDataSourceLocked;
|
||||
@ -174,8 +174,6 @@ void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||
|
||||
_leadingScreensForBatching = 1.0;
|
||||
_batchContext = [[ASBatchContext alloc] init];
|
||||
|
||||
_pendingVisibleIndexPaths = [[NSMutableSet alloc] init];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
|
||||
@ -433,7 +431,7 @@ void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||
|
||||
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[_pendingVisibleIndexPaths addObject:indexPath];
|
||||
_pendingVisibleIndexPath = indexPath;
|
||||
|
||||
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
|
||||
|
||||
@ -444,8 +442,8 @@ void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath
|
||||
{
|
||||
if ([_pendingVisibleIndexPaths containsObject:indexPath]) {
|
||||
[_pendingVisibleIndexPaths removeObject:indexPath];
|
||||
if ([_pendingVisibleIndexPath isEqual:indexPath]) {
|
||||
_pendingVisibleIndexPath = nil;
|
||||
}
|
||||
|
||||
[_rangeController visibleNodeIndexPathsDidChangeWithScrollDirection:self.scrollDirection];
|
||||
@ -519,15 +517,20 @@ void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
NSMutableSet *visibleIndexPaths = [NSMutableSet setWithArray:[self indexPathsForVisibleRows]];
|
||||
NSArray *visibleIndexPaths = self.indexPathsForVisibleRows;
|
||||
|
||||
// First, remove any index paths we're tracking that UIKit has now proven it can remember :)
|
||||
[_pendingVisibleIndexPaths minusSet:visibleIndexPaths];
|
||||
if ( _pendingVisibleIndexPath ) {
|
||||
NSMutableSet *indexPaths = [NSMutableSet setWithArray:self.indexPathsForVisibleRows];
|
||||
|
||||
// Next, add all remaining index paths that we know should be visible (from willDisplayCell) but are not in the set.
|
||||
[visibleIndexPaths unionSet:_pendingVisibleIndexPaths];
|
||||
if ( [indexPaths containsObject:_pendingVisibleIndexPath]) {
|
||||
_pendingVisibleIndexPath = nil; // once it has shown up in visibleIndexPaths, we can stop tracking it
|
||||
} else {
|
||||
[indexPaths addObject:_pendingVisibleIndexPath];
|
||||
visibleIndexPaths = indexPaths.allObjects;
|
||||
}
|
||||
}
|
||||
|
||||
return visibleIndexPaths.allObjects;
|
||||
return visibleIndexPaths;
|
||||
}
|
||||
|
||||
- (NSArray *)rangeController:(ASRangeController *)rangeController nodesAtIndexPaths:(NSArray *)indexPaths
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user