Merge branch 'charlesmchen/asyncDatabaseViewRegistrationVsExportWithSignal'

pull/1/head
Matthew Chen 8 years ago
commit 8d4f30d19e

@ -416,20 +416,14 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
} }
DDLogInfo(@"Application opened with URL: %@", url); DDLogInfo(@"Application opened with URL: %@", url);
[[TSAccountManager sharedInstance] [[TSAccountManager sharedInstance] ifRegistered:YES
ifRegistered:YES runAsync:^{
runAsync:^{ dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{ // Wait up to N seconds for database view registrations to
SendExternalFileViewController *viewController = [SendExternalFileViewController new]; // complete.
viewController.attachment = attachment; [self showImportUIForAttachment:attachment remainingRetries:5];
UINavigationController *navigationController = });
[[UINavigationController alloc] initWithRootViewController:viewController]; }];
[[[Environment getCurrent] signalsViewController]
presentTopLevelModalViewController:navigationController
animateDismissal:NO
animatePresentation:YES];
});
}];
return YES; return YES;
} else { } else {
@ -438,6 +432,35 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
return NO; return NO;
} }
- (void)showImportUIForAttachment:(SignalAttachment *)attachment remainingRetries:(int)remainingRetries
{
OWSAssert([NSThread isMainThread]);
OWSAssert(attachment);
OWSAssert(remainingRetries > 0);
if ([TSDatabaseView hasPendingViewRegistrations]) {
if (remainingRetries < 1) {
DDLogInfo(@"Ignoring 'Import with Signal...' due to pending view registrations.");
} else {
DDLogInfo(@"Delaying 'Import with Signal...' due to pending view registrations.");
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
if (![TSDatabaseView hasPendingViewRegistrations]) {
[self showImportUIForAttachment:attachment remainingRetries:remainingRetries - 1];
}
});
}
return;
}
SendExternalFileViewController *viewController = [SendExternalFileViewController new];
viewController.attachment = attachment;
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:viewController];
[[[Environment getCurrent] signalsViewController] presentTopLevelModalViewController:navigationController
animateDismissal:NO
animatePresentation:YES];
}
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
DDLogWarn(@"%@ applicationDidBecomeActive.", self.tag); DDLogWarn(@"%@ applicationDidBecomeActive.", self.tag);

Loading…
Cancel
Save