Fix display of pairing failure dialog when machine is streaming

This commit is contained in:
Cameron Gutman
2017-05-07 16:51:57 -07:00
parent f6b225ca9c
commit dd33f57b9a
@@ -49,6 +49,7 @@ static NSMutableSet* hostList;
message:[NSString stringWithFormat:@"Enter the following PIN on the host machine: %@", PIN] message:[NSString stringWithFormat:@"Enter the following PIN on the host machine: %@", PIN]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
[_pairAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action) { [_pairAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action) {
_pairAlert = nil;
[_discMan startDiscovery]; [_discMan startDiscovery];
[self hideLoadingFrame]; [self hideLoadingFrame];
}]]; }]];
@@ -56,24 +57,36 @@ static NSMutableSet* hostList;
}); });
} }
- (void)displayFailureDialog:(NSString *)message {
UIAlertController* failedDialog = [UIAlertController alertControllerWithTitle:@"Pairing Failed"
message:message
preferredStyle:UIAlertControllerStyleAlert];
[failedDialog addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:nil]];
[self presentViewController:failedDialog animated:YES completion:nil];
[_discMan startDiscovery];
[self hideLoadingFrame];
}
- (void)pairFailed:(NSString *)message { - (void)pairFailed:(NSString *)message {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[_pairAlert dismissViewControllerAnimated:YES completion:^{ if (_pairAlert != nil) {
_pairAlert = [UIAlertController alertControllerWithTitle:@"Pairing Failed" [_pairAlert dismissViewControllerAnimated:YES completion:^{
message:message [self displayFailureDialog:message];
preferredStyle:UIAlertControllerStyleAlert]; }];
[_pairAlert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:nil]]; _pairAlert = nil;
[self presentViewController:_pairAlert animated:YES completion:nil]; }
else {
[_discMan startDiscovery]; [self displayFailureDialog:message];
[self hideLoadingFrame]; }
}];
}); });
} }
- (void)pairSuccessful { - (void)pairSuccessful {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[_pairAlert dismissViewControllerAnimated:YES completion:nil]; [_pairAlert dismissViewControllerAnimated:YES completion:nil];
_pairAlert = nil;
[_discMan startDiscovery]; [_discMan startDiscovery];
[self alreadyPaired]; [self alreadyPaired];
}); });