[ASDKgram] Perform batch-fetching updates on main (#2972)

This commit is contained in:
Adlai Holler
2017-02-02 14:03:40 -08:00
committed by GitHub
parent d42dcfefc1
commit bf2363cb8f

View File

@@ -69,18 +69,20 @@ ASIGSectionControllerCellForIndexImplementation;
- (void)beginBatchFetchWithContext:(ASBatchContext *)context
{
// Immediately add the loading spinner if needed.
if (self.items.count > 0) {
NSArray *newItems = [self.items arrayByAddingObject:_paginatingSpinner];
[self setItems:newItems animated:NO completion:nil];
}
dispatch_async(dispatch_get_main_queue(), ^{
// Immediately add the loading spinner if needed.
if (self.items.count > 0) {
NSArray *newItems = [self.items arrayByAddingObject:_paginatingSpinner];
[self setItems:newItems animated:NO completion:nil];
}
// Start the fetch, then update the items (removing the spinner) when they are loaded.
[_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){
[self setItems:_photoFeed.photos animated:NO completion:^{
[context completeBatchFetching:YES];
}];
} numResultsToReturn:20];
// Start the fetch, then update the items (removing the spinner) when they are loaded.
[_photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){
[self setItems:_photoFeed.photos animated:NO completion:^{
[context completeBatchFetching:YES];
}];
} numResultsToReturn:20];
});
}
#pragma mark - RefreshingSectionControllerType