Merge branch 'charlesmchen/asyncDatabaseViewRegistrationVsExportWithSignal'

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

@ -416,18 +416,12 @@ 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(), ^{
SendExternalFileViewController *viewController = [SendExternalFileViewController new]; // Wait up to N seconds for database view registrations to
viewController.attachment = attachment; // complete.
UINavigationController *navigationController = [self showImportUIForAttachment:attachment remainingRetries:5];
[[UINavigationController alloc] initWithRootViewController:viewController];
[[[Environment getCurrent] signalsViewController]
presentTopLevelModalViewController:navigationController
animateDismissal:NO
animatePresentation:YES];
}); });
}]; }];
@ -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