Skip to content

Commit f8e1655

Browse files
committed
Rewrite code pattern of dispatch main queue in completionHandler
1 parent 4f0a96b commit f8e1655

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,25 @@ -(void)dealloc
8888

8989
- (void)startWithCompletionHandler:(MSIDWebUICompletionHandler)completionHandler
9090
{
91-
// If we're not on the main thread when trying to kick up the UI then
92-
// dispatch over to the main thread.
93-
if (![NSThread isMainThread])
94-
{
95-
dispatch_async(dispatch_get_main_queue(), ^{
96-
[self startWithCompletionHandler:completionHandler];
97-
});
98-
return;
99-
}
100-
10191
// Save the completion block
10292
_completionHandler = [completionHandler copy];
10393

104-
NSError *error = nil;
105-
[self loadView:&error];
106-
if (error)
107-
{
108-
[self endWebAuthWithURL:nil error:error];
109-
return;
110-
}
111-
112-
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_startURL];
113-
for (NSString *headerKey in _customHeaders)
114-
[request addValue:_customHeaders[headerKey] forHTTPHeaderField:headerKey];
94+
dispatch_async(dispatch_get_main_queue(), ^{
11595

116-
[self startRequest:request];
96+
NSError *error = nil;
97+
[self loadView:&error];
98+
if (error)
99+
{
100+
[self endWebAuthWithURL:nil error:error];
101+
return;
102+
}
103+
104+
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_startURL];
105+
for (NSString *headerKey in _customHeaders)
106+
[request addValue:_customHeaders[headerKey] forHTTPHeaderField:headerKey];
107+
108+
[self startRequest:request];
109+
});
117110
}
118111

119112
- (void)cancel

0 commit comments

Comments
 (0)