mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Clean up supplementary nodes in data controller store on each reload
This commit is contained in:
@@ -47,7 +47,13 @@
|
|||||||
- (void)willReloadData
|
- (void)willReloadData
|
||||||
{
|
{
|
||||||
[_pendingNodes enumerateKeysAndObjectsUsingBlock:^(NSString *kind, NSMutableArray *nodes, BOOL *stop) {
|
[_pendingNodes enumerateKeysAndObjectsUsingBlock:^(NSString *kind, NSMutableArray *nodes, BOOL *stop) {
|
||||||
LOG(@"Batch layout nodes of kind: %@, (%@)", kind, nodes);
|
// Remove everything that existed before the reload, now that we're ready to insert replacements
|
||||||
|
NSArray *indexPaths = [self indexPathsForEditingNodesOfKind:kind];
|
||||||
|
[self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil];
|
||||||
|
|
||||||
|
NSArray *editingNodes = [self editingNodesOfKind:kind];
|
||||||
|
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, editingNodes.count)];
|
||||||
|
[self deleteSectionsOfKind:kind atIndexSet:indexSet completion:nil];
|
||||||
|
|
||||||
// Insert each section
|
// Insert each section
|
||||||
NSUInteger sectionCount = [self.collectionDataSource dataController:self numberOfSectionsForSupplementaryKind:kind];
|
NSUInteger sectionCount = [self.collectionDataSource dataController:self numberOfSectionsForSupplementaryKind:kind];
|
||||||
@@ -60,6 +66,8 @@
|
|||||||
[self batchLayoutNodes:nodes ofKind:kind atIndexPaths:_pendingIndexPaths[kind] completion:^(NSArray *nodes, NSArray *indexPaths) {
|
[self batchLayoutNodes:nodes ofKind:kind atIndexPaths:_pendingIndexPaths[kind] completion:^(NSArray *nodes, NSArray *indexPaths) {
|
||||||
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
[self insertNodes:nodes ofKind:kind atIndexPaths:indexPaths completion:nil];
|
||||||
}];
|
}];
|
||||||
|
_pendingNodes[kind] = [NSArray array];
|
||||||
|
_pendingIndexPaths[kind] = [NSArray array];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,21 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses can override this to reload data after the abstract data controller deletes its old data and before it reloads the new.
|
* Subclasses can override this to reload data after the abstract data controller deletes its old data and before it reloads the new.
|
||||||
|
*
|
||||||
|
* @discussion Invoked on the editing transaction queue.
|
||||||
*/
|
*/
|
||||||
- (void)willReloadData;
|
- (void)willReloadData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a collection of index paths for nodes of the given kind that are currently in the editing store
|
||||||
|
*/
|
||||||
|
- (NSArray *)indexPathsForEditingNodesOfKind:(NSString *)kind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read-only access to the underlying editing nodes of the given kind
|
||||||
|
*/
|
||||||
|
- (NSArray *)editingNodesOfKind:(NSString *)kind;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read only access to the underlying completed nodes of the given kind
|
* Read only access to the underlying completed nodes of the given kind
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -786,6 +786,16 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
|
|
||||||
#pragma mark - Data Querying (Subclass API)
|
#pragma mark - Data Querying (Subclass API)
|
||||||
|
|
||||||
|
- (NSArray *)indexPathsForEditingNodesOfKind:(NSString *)kind
|
||||||
|
{
|
||||||
|
return _editingNodes[kind] != nil ? ASIndexPathsForMultidimensionalArray(_editingNodes[kind]) : [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)editingNodesOfKind:(NSString *)kind
|
||||||
|
{
|
||||||
|
return _editingNodes[kind] != nil ? _editingNodes[kind] : [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSArray *)completedNodesOfKind:(NSString *)kind
|
- (NSArray *)completedNodesOfKind:(NSString *)kind
|
||||||
{
|
{
|
||||||
return _completedNodes[kind];
|
return _completedNodes[kind];
|
||||||
|
|||||||
Reference in New Issue
Block a user