Skip to content

Fix initialization of Facebook/Twitter Utils blocking the main thread. #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 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
2 changes: 1 addition & 1 deletion Parse/Internal/PFCoreManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ - (PFUserAuthenticationController *)userAuthenticationController {
__block PFUserAuthenticationController *controller = nil;
dispatch_sync(_controllerAccessQueue, ^{
if (!_userAuthenticationController) {
_userAuthenticationController = [[PFUserAuthenticationController alloc] init];
_userAuthenticationController = [PFUserAuthenticationController controllerWithDataSource:self];
}
controller = _userAuthenticationController;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
#import <Parse/PFConstants.h>
#import <Parse/PFUserAuthenticationDelegate.h>

#import "PFCoreDataProvider.h"

NS_ASSUME_NONNULL_BEGIN

@class BFTask PF_GENERIC(__covariant BFGenericType);
@class PFUser;

@interface PFUserAuthenticationController : NSObject

@property (nonatomic, weak, readonly) id<PFCurrentUserControllerProvider> dataSource;

///--------------------------------------
/// @name Init
///--------------------------------------

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

- (instancetype)initWithDataSource:(id<PFCurrentUserControllerProvider>)dataSource;
+ (instancetype)controllerWithDataSource:(id<PFCurrentUserControllerProvider>)dataSource;

///--------------------------------------
/// @name Authentication Providers
///--------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#import "PFAnonymousUtils.h"
#import "PFAnonymousAuthenticationProvider.h"
#import "PFUserController.h"
#import "PFCurrentUserController.h"
#import "PFAssert.h"

@interface PFUserAuthenticationController () {
Expand All @@ -31,16 +32,21 @@ @implementation PFUserAuthenticationController
#pragma mark - Init
///--------------------------------------

- (instancetype)init {
- (instancetype)initWithDataSource:(id<PFCurrentUserControllerProvider>)dataSource {
self = [super init];
if (!self) return nil;

_dataSource = dataSource;
_dataAccessQueue = dispatch_queue_create("com.parse.user.authenticationManager", DISPATCH_QUEUE_SERIAL);
_authenticationDelegates = [NSMutableDictionary dictionary];

return self;
}

+ (instancetype)controllerWithDataSource:(id<PFCurrentUserControllerProvider>)dataSource {
return [[self alloc] initWithDataSource:dataSource];
}

///--------------------------------------
#pragma mark - Authentication Providers
///--------------------------------------
Expand All @@ -56,9 +62,11 @@ - (void)registerAuthenticationDelegate:(id<PFUserAuthenticationDelegate>)delegat
});

// TODO: (nlutsenko) Decouple this further.
if (![authType isEqualToString:PFAnonymousUserAuthenticationType]) {
[[PFUser currentUser] synchronizeAuthDataWithAuthType:authType];
}
[[self.dataSource.currentUserController getCurrentUserAsyncWithOptions:0] continueWithSuccessBlock:^id(BFTask *task) {
PFUser *user = task.result;
[user synchronizeAuthDataWithAuthType:authType];
return nil;
}];
}

- (void)unregisterAuthenticationDelegateForAuthType:(NSString *)authType {
Expand Down