mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
fix
This commit is contained in:
@@ -205,22 +205,40 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
|||||||
#pragma mark - Data Update
|
#pragma mark - Data Update
|
||||||
|
|
||||||
- (void)insertSections:(NSIndexSet *)indexSet {
|
- (void)insertSections:(NSIndexSet *)indexSet {
|
||||||
NSMutableArray *sectionArray = [[NSMutableArray alloc] initWithCapacity:indexSet.count];
|
__block int nodeTotalCnt = 0;
|
||||||
for (NSUInteger i = 0; i < indexSet.count; i++) {
|
NSMutableArray *nodeCounts = [NSMutableArray arrayWithCapacity:indexSet.count];
|
||||||
NSUInteger rowNum = [_dataSource dataController:self rowsInSection:i];
|
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
NSMutableArray *rows = [[NSMutableArray alloc] initWithCapacity:rowNum];
|
NSUInteger cnt = [_dataSource dataController:self rowsInSection:idx];
|
||||||
|
[nodeCounts addObject:@(cnt)];
|
||||||
|
nodeTotalCnt += cnt;
|
||||||
|
}];
|
||||||
|
|
||||||
for (NSUInteger j = 0; j < rowNum; j++) {
|
NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:nodeTotalCnt];
|
||||||
ASCellNode *node = [_dataSource dataController:self nodeAtIndexPath:[NSIndexPath indexPathForItem:j inSection:i]];
|
NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:nodeTotalCnt];
|
||||||
[rows addObject:node];
|
|
||||||
}
|
__block NSUInteger idx = 0;
|
||||||
[sectionArray addObject:rows];
|
[indexSet enumerateIndexesUsingBlock:^(NSUInteger sectionIdx, BOOL *stop) {
|
||||||
|
NSUInteger cnt = [nodeCounts[idx++] unsignedIntegerValue];
|
||||||
|
|
||||||
|
for (int i = 0; i < cnt; i++) {
|
||||||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:sectionIdx];
|
||||||
|
[indexPaths addObject:indexPath];
|
||||||
|
|
||||||
|
ASCellNode *node = [_dataSource dataController:self nodeAtIndexPath:indexPath];
|
||||||
|
[nodes addObject:node];
|
||||||
}
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
dispatch_async([[self class] sizingQueue], ^{
|
dispatch_async([[self class] sizingQueue], ^{
|
||||||
[self asyncUpdateDataWithBlock:^{
|
[self syncUpdateDataWithBlock:^{
|
||||||
|
NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:indexSet.count];
|
||||||
|
for (NSUInteger i = 0; i < indexSet.count; i++) {
|
||||||
|
[sectionArray addObject:[NSMutableArray array]];
|
||||||
|
}
|
||||||
INSERT_SECTIONS(_nodes , indexSet, sectionArray);
|
INSERT_SECTIONS(_nodes , indexSet, sectionArray);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[self _insertNodes:nodes atIndexPaths:indexPaths];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ static const CGFloat kASFlowLayoutControllerRefreshingThreshold = 0.3;
|
|||||||
__block int cnt = 0;
|
__block int cnt = 0;
|
||||||
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
NSArray *nodes = sections[cnt++];
|
NSArray *nodes = sections[cnt++];
|
||||||
std::vector<CGSize> v(nodes.count);
|
std::vector<CGSize> v;
|
||||||
|
v.reserve(nodes.count);
|
||||||
|
|
||||||
for (int i = 0; i < nodes.count; i++) {
|
for (int i = 0; i < nodes.count; i++) {
|
||||||
v.push_back([nodes[i] CGSizeValue]);
|
v.push_back([nodes[i] CGSizeValue]);
|
||||||
|
|||||||
Reference in New Issue
Block a user