Skip to content
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 @@ -10,6 +10,7 @@
#import "PFOfflineQueryLogic.h"

#import <Bolts/BFTask.h>
#import <Bolts/BFExecutor.h>

#import "PFACL.h"
#import "PFAssert.h"
Expand Down Expand Up @@ -695,7 +696,7 @@ - (BFTask *)fetchIncludeAsync:(NSString *)include
rest = [[parts subarrayWithRange:range] componentsJoinedByString:@"."];
}

return [[[BFTask taskWithResult:nil] continueWithBlock:^id(BFTask *task) {
return [[BFTask taskFromExecutor:[BFExecutor defaultExecutor] withBlock:^id{
if ([container isKindOfClass:[PFObject class]]) {
BFTask *fetchTask = [self fetchIncludeAsync:nil container:container database:database];
return [fetchTask continueWithSuccessBlock:^id(BFTask *task) {
Expand Down
22 changes: 11 additions & 11 deletions Parse/Internal/LocalDataStore/OfflineStore/PFOfflineStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ - (BFTask *)fetchObjectLocallyAsync:(PFObject *)object database:(PFSQLiteDatabas
// The object has been fetched from offline store, so any data that's in there
// is already reflected in the in-memory version. There's nothing more to do.
return [fetchTask continueWithBlock:^id(BFTask *task) {
return [BFTask taskWithResult:[task.result weakObject]];
return [task.result weakObject];
}];
}

// Put a placeholder so that anyone else who attempts to fetch this object will just
// wait for this call to finish doing it.
[self.fetchedObjects setObject:[tcs.task continueWithBlock:^id(BFTask *task) {
return [BFTask taskWithResult:[PFWeakValue valueWithWeakObject:task.result]];
return [PFWeakValue valueWithWeakObject:task.result];
}] forKey:object];
uuidTask = [self.objectToUUIDMap objectForKey:object];
}
Expand Down Expand Up @@ -277,7 +277,7 @@ - (BFTask *)fetchObjectLocallyAsync:(PFObject *)object database:(PFSQLiteDatabas
return [[BFTask taskForCompletionOfAllTasks:objectValues] continueWithSuccessBlock:^id(BFTask *task) {
PFDecoder *decoder = [PFOfflineDecoder decoderWithOfflineObjects:offlineObjects];
[object mergeFromRESTDictionary:parsedJson withDecoder:decoder];
return [BFTask taskWithResult:nil];
return nil;
}];
}] continueWithBlock:^id(BFTask *task) {
if (task.isCancelled) {
Expand Down Expand Up @@ -353,7 +353,7 @@ - (BFTask *)saveObjectLocallyAsync:(PFObject *)object
NSString *uuid = task.result;
if (uuid == nil) {
// The root object was never stored in offline store, so nothing unpin.
return [BFTask taskWithResult:nil];
return nil;
}

// Delete all objects locally corresponding to the key we're trying to use in case it was
Expand Down Expand Up @@ -531,14 +531,14 @@ - (BFTask *)findAsyncForQueryState:(PFQueryState *)queryState
return [self fetchObjectLocallyAsync:object database:database];
}] continueWithSuccessBlock:^id(BFTask *task) {
if (!object.dataAvailable) {
return [BFTask taskWithResult:@NO];
return @NO;
}
return matcherBlock(object, database);
}] continueWithSuccessBlock:^id(BFTask *task) {
if ([task.result boolValue]) {
[mutableResults addObject:object];
}
return [BFTask taskWithResult:nil];
return nil;
}];
}
[result close];
Expand Down Expand Up @@ -588,9 +588,9 @@ - (BFTask *)updateDataForObjectAsync:(PFObject *)object {
if (task.error != nil) {
// Catch CACHE_MISS errors and ignore them.
if (task.error.code == kPFErrorCacheMiss) {
return [BFTask taskWithResult:nil];
return nil;
}
return [BFTask taskWithResult:[task.result weakObject]];
return [task.result weakObject];
}

return [self _performDatabaseTransactionAsyncWithBlock:^BFTask *(PFSQLiteDatabase *database) {
Expand Down Expand Up @@ -751,7 +751,7 @@ - (BFTask *)unpinObjectAsync:(PFObject *)object {
NSString *uuid = task.result;
if (!uuid) {
// The root object was never stored in the offline store, so nothing to unpin.
return [BFTask taskWithResult:nil];
return nil;
}
return [self _unpinKeyAsync:uuid];
}];
Expand Down Expand Up @@ -798,7 +798,7 @@ - (BFTask *)_unpinKeyAsync:(NSString *)key database:(PFSQLiteDatabase *)database
}
}
}
return [BFTask taskWithResult:nil];
return nil;
}];
}

Expand Down Expand Up @@ -861,7 +861,7 @@ - (BFTask *)getOrCreateUUIDAsyncForObject:(PFObject *)object
[[database executeSQLAsync:query
withArgumentsInArray:@[ newUUID, [object parseClassName]]] continueWithSuccessBlock:^id(BFTask *task) {
[tcs setResult:newUUID];
return [BFTask taskWithResult:nil];
return nil;
}];

return tcs.task;
Expand Down
4 changes: 2 additions & 2 deletions Parse/Internal/LocalDataStore/SQLite/PFSQLiteDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ - (BFTask *)openAsync {
}

self.database = db;
return [BFTask taskWithResult:nil];
return nil;
}];
}

Expand Down Expand Up @@ -242,7 +242,7 @@ - (BFTask *)executeSQLAsync:(NSString *)sql withArgumentsInArray:(NSArray *)args

switch (sqliteResultCode) {
case SQLITE_DONE: {
return [BFTask taskWithResult:nil];
return nil;
}
case SQLITE_ROW: {
NSError *error = [self _errorWithErrorCode:PFSQLiteDatabaseInvalidSQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (BFTask *)processFetchResultAsync:(NSDictionary *)result forObject:(PFObject *
// Catch CACHE_MISS and ignore it.
if ([task.error.domain isEqualToString:PFParseErrorDomain] &&
task.error.code == kPFErrorCacheMiss) {
return [BFTask taskWithResult:nil];
return nil;
}
return task;
}];
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFCommandCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ - (BFTask *)_cleanupDiskCacheWithRequiredFreeSize:(NSUInteger)requiredSize {
}
}

return [BFTask taskWithResult:nil];
return nil;
}];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ - (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType {
return [BFTask taskWithResult:@YES];
}
return [BFTask taskFromExecutor:[BFExecutor defaultPriorityBackgroundExecutor] withBlock:^id {
return [BFTask taskWithResult:@([provider restoreAuthenticationWithAuthData:authData])];
return @([provider restoreAuthenticationWithAuthData:authData]);
}];
}

Expand Down Expand Up @@ -159,7 +159,7 @@ - (BFTask *)logInUserAsyncWithAuthType:(NSString *)authType authData:(NSDictiona
}
}

return [BFTask taskWithResult:currentUser];
return currentUser;
}];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,9 @@ - (BFTask *)_loadCurrentUserFromDiskAsync {
task = [[query findObjectsInBackground] continueWithSuccessBlock:^id(BFTask *task) {
NSArray *results = task.result;
if ([results count] == 1) {
return [BFTask taskWithResult:results.firstObject];
return results.firstObject;
} else if ([results count] != 0) {
return [[PFObject unpinAllObjectsInBackgroundWithName:PFUserCurrentUserPinName]
continueWithSuccessResult:nil];
return [[PFObject unpinAllObjectsInBackgroundWithName:PFUserCurrentUserPinName] continueWithSuccessResult:nil];
}

// Backward compatibility if we previously have non-LDS currentUser.
Expand Down
4 changes: 2 additions & 2 deletions Parse/PFFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ - (BFTask *)_uploadAsyncWithProgressBlock:(PFProgressBlock)progressBlock {
return [self.taskQueue enqueue:^id(BFTask *task) {
if (!self.dirty) {
[self _performProgressBlockAsync:progressBlock withProgress:100];
return [BFTask taskWithResult:nil];
return nil;
}

return [self _uploadFileAsyncWithSessionToken:sessionToken
Expand Down Expand Up @@ -388,7 +388,7 @@ - (BFTask *)_downloadAsyncWithProgressBlock:(PFProgressBlock)progressBlock {
@strongify(self);
if (self.dataAvailable) {
[self _performProgressBlockAsync:progressBlock withProgress:100];
return [BFTask taskWithResult:nil];
return nil;
}

PFFileController *controller = [[self class] fileController];
Expand Down
10 changes: 4 additions & 6 deletions Parse/PFObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ - (BFTask *)_enqueueSaveEventuallyWithChildren:(BOOL)saveChildren {
@synchronized (lock) {
[self _objectWillSave];
if (![self isDirty:NO]) {
return [BFTask taskWithResult:@YES];
return @YES;
}
}

Expand Down Expand Up @@ -1332,11 +1332,9 @@ - (void)_mergeFromServerWithResult:(NSDictionary *)result decoder:(PFDecoder *)d
// to add special actions after operations.

- (BFTask *)handleSaveResultAsync:(NSDictionary *)result {
BFTask *task = [BFTask taskWithResult:nil];

NSDictionary *fetchedObjects = [self _collectFetchedObjects];

[task continueWithBlock:^id(BFTask *task) {
BFTask *task = [BFTask taskFromExecutor:[BFExecutor defaultExecutor] withBlock:^id{
PFKnownParseObjectDecoder *decoder = [PFKnownParseObjectDecoder decoderWithFetchedObjects:fetchedObjects];
@synchronized (self.lock) {
// TODO (hallucinogen): t5611821 we need to make mergeAfterSave that accepts decoder and operationBeforeSave
Expand All @@ -1357,7 +1355,7 @@ - (BFTask *)handleSaveResultAsync:(NSDictionary *)result {
if (self.saveDelegate) {
[self.saveDelegate invoke:self error:nil];
}
return [BFTask taskWithResult:@(!!result)];
return @(result != nil);
}
}];
}
Expand Down Expand Up @@ -1388,7 +1386,7 @@ - (BFTask *)saveAsync:(BFTask *)toAwait {
}] continueWithBlock:^id(BFTask *task) {
@synchronized (lock) {
if (![self isDirty:YES]) {
return [BFTask taskWithResult:@YES];
return @YES;
}

[self _objectWillSave];
Expand Down
4 changes: 2 additions & 2 deletions Parse/PFQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ - (BFTask *)_getObjectWithIdAsync:(NSString *)objectId cachePolicy:(PFCachePolic
return [BFTask taskWithError:[PFQueryUtilities objectNotFoundError]];
}

return [BFTask taskWithResult:objects.lastObject];
return objects.lastObject;
}];
}

Expand Down Expand Up @@ -904,7 +904,7 @@ - (BFTask *)_getFirstObjectAsyncWithCachePolicy:(PFCachePolicy)cachePolicy after
return [BFTask taskWithError:[PFQueryUtilities objectNotFoundError]];
}

return [BFTask taskWithResult:objects.lastObject];
return objects.lastObject;
}];
}

Expand Down
6 changes: 3 additions & 3 deletions Parse/PFUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ - (BFTask *)_handleServiceLoginCommandResult:(PFCommandResult *)result {
return self;
}];
}
return [BFTask taskWithResult:self];
return self;
}
}];
}];
Expand Down Expand Up @@ -699,7 +699,7 @@ + (BFTask *)_upgradeToRevocableSessionInBackground {

// Bail-out early if session token is already revocable.
if ([PFSessionUtilities isSessionTokenRevocable:sessionToken]) {
return [BFTask taskWithResult:currentUser];
return currentUser;
}
return [currentUser _upgradeToRevocableSessionInBackground];
}];
Expand All @@ -718,7 +718,7 @@ - (BFTask *)_upgradeToRevocableSessionInBackground {

// Check session token here as well, to make sure we didn't upgrade the token in between.
if ([PFSessionUtilities isSessionTokenRevocable:token]) {
return [BFTask taskWithResult:self];
return self;
}

PFRESTCommand *command = [PFRESTUserCommand upgradeToRevocableSessionCommandWithSessionToken:token];
Expand Down