mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Don’t show “export with Signal” UI until async database view registration is complete.
// FREEBIE
This commit is contained in:
parent
66a71d7241
commit
9f2a2d1ee6
1 changed files with 37 additions and 14 deletions
|
@ -416,20 +416,14 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
}
|
||||
DDLogInfo(@"Application opened with URL: %@", url);
|
||||
|
||||
[[TSAccountManager sharedInstance]
|
||||
ifRegistered:YES
|
||||
runAsync:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SendExternalFileViewController *viewController = [SendExternalFileViewController new];
|
||||
viewController.attachment = attachment;
|
||||
UINavigationController *navigationController =
|
||||
[[UINavigationController alloc] initWithRootViewController:viewController];
|
||||
[[[Environment getCurrent] signalsViewController]
|
||||
presentTopLevelModalViewController:navigationController
|
||||
animateDismissal:NO
|
||||
animatePresentation:YES];
|
||||
});
|
||||
}];
|
||||
[[TSAccountManager sharedInstance] ifRegistered:YES
|
||||
runAsync:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Wait up to N seconds for database view registrations to
|
||||
// complete.
|
||||
[self showImportUIForAttachment:attachment remainingRetries:5];
|
||||
});
|
||||
}];
|
||||
|
||||
return YES;
|
||||
} else {
|
||||
|
@ -438,6 +432,35 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
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 {
|
||||
DDLogWarn(@"%@ applicationDidBecomeActive.", self.tag);
|
||||
|
||||
|
|
Loading…
Reference in a new issue