Display a loading spinner while adding a PC is in progress

This commit is contained in:
Cameron Gutman
2020-08-30 20:39:11 -07:00
parent dbab07838d
commit 6bf643968b
@@ -536,14 +536,17 @@ static NSMutableSet* hostList;
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
NSString* hostAddress = ((UITextField*)[[alertController textFields] objectAtIndex:0]).text; NSString* hostAddress = ((UITextField*)[[alertController textFields] objectAtIndex:0]).text;
[self showLoadingFrame:^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
[self->_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){ [self->_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){
if (host != nil) { if (host != nil) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self hideLoadingFrame:^{
@synchronized(hostList) { @synchronized(hostList) {
[hostList addObject:host]; [hostList addObject:host];
} }
[self updateHosts]; [self updateHosts];
}];
}); });
} else { } else {
unsigned int portTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443, unsigned int portTestResults = LiTestClientConnectivity(CONN_TEST_SERVER, 443,
@@ -556,10 +559,14 @@ static NSMutableSet* hostList;
[Utils addHelpOptionToDialog:hostNotFoundAlert]; [Utils addHelpOptionToDialog:hostNotFoundAlert];
[hostNotFoundAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]]; [hostNotFoundAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self hideLoadingFrame:^{
[[self activeViewController] presentViewController:hostNotFoundAlert animated:YES completion:nil]; [[self activeViewController] presentViewController:hostNotFoundAlert animated:YES completion:nil];
}];
}); });
} }
}];}); }];
});
}];
}]]; }]];
[alertController addTextFieldWithConfigurationHandler:nil]; [alertController addTextFieldWithConfigurationHandler:nil];
[[self activeViewController] presentViewController:alertController animated:YES completion:nil]; [[self activeViewController] presentViewController:alertController animated:YES completion:nil];