Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Fix never succesfully completed task of -loadObjects in Query/Collection View Controllers. #212

Merged
merged 1 commit into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ - (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
self.loading = YES;
[self objectsWillLoad];

BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource];

PFQuery *query = [self queryForCollection];
[self _alterQuery:query forLoadingPage:page];

BFTaskCompletionSource PF_GENERIC(NSArray<__kindof PFObject *>*)*source = [BFTaskCompletionSource taskCompletionSource];
[query findObjectsInBackgroundWithBlock:^(NSArray *foundObjects, NSError *error) {
if (![Parse isLocalDatastoreEnabled] &&
query.cachePolicy != kPFCachePolicyCacheOnly &&
Expand Down Expand Up @@ -266,9 +266,12 @@ - (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
[self objectsDidLoad:error];
[self.refreshControl endRefreshing];

[source setError:error];
if (error) {
[source trySetError:error];
} else {
[source trySetResult:foundObjects];
}
}];

return source.task;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ - (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
self.loading = YES;
[self objectsWillLoad];

BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource];

PFQuery *query = [self queryForTable];
[self _alterQuery:query forLoadingPage:page];

BFTaskCompletionSource PF_GENERIC(NSArray<__kindof PFObject *>*)*source = [BFTaskCompletionSource taskCompletionSource];
[query findObjectsInBackgroundWithBlock:^(NSArray *foundObjects, NSError *error) {
if (![Parse isLocalDatastoreEnabled] &&
query.cachePolicy != kPFCachePolicyCacheOnly &&
Expand Down Expand Up @@ -252,7 +252,11 @@ - (BFTask *)loadObjects:(NSInteger)page clear:(BOOL)clear {
[self objectsDidLoad:error];
[self.refreshControl endRefreshing];

[source setError:error];
if (error) {
[source trySetError:error];
} else {
[source trySetResult:foundObjects];
}
}];

return source.task;
Expand Down