|
|
@ -394,14 +394,13 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DDLogInfo(@"Application opened with URL: %@", url);
|
|
|
|
DDLogInfo(@"Application opened with URL: %@", url);
|
|
|
|
|
|
|
|
|
|
|
|
[[TSAccountManager sharedInstance] ifRegistered:YES
|
|
|
|
if ([TSAccountManager isRegistered]) {
|
|
|
|
runAsync:^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
// Wait up to N seconds for database view registrations to
|
|
|
|
// Wait up to N seconds for database view registrations to
|
|
|
|
// complete.
|
|
|
|
// complete.
|
|
|
|
[self showImportUIForAttachment:attachment remainingRetries:5];
|
|
|
|
[self showImportUIForAttachment:attachment remainingRetries:5];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
return YES;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -455,70 +454,52 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|
|
|
|
|
|
|
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
|
|
|
|
RTCInitializeSSL();
|
|
|
|
|
|
|
|
|
|
|
|
// At this point, potentially lengthy DB locking migrations could be running.
|
|
|
|
if ([TSAccountManager isRegistered]) {
|
|
|
|
// Avoid blocking app launch by putting all further possible DB access in async thread.
|
|
|
|
// At this point, potentially lengthy DB locking migrations could be running.
|
|
|
|
[[TSAccountManager sharedInstance]
|
|
|
|
// Avoid blocking app launch by putting all further possible DB access in async block
|
|
|
|
ifRegistered:YES
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
runAsync:^{
|
|
|
|
DDLogInfo(
|
|
|
|
DDLogInfo(@"%@ running post launch block for registered user: %@",
|
|
|
|
@"%@ running post launch block for registered user: %@", self.tag, [TSAccountManager localNumber]);
|
|
|
|
self.tag,
|
|
|
|
|
|
|
|
[TSAccountManager localNumber]);
|
|
|
|
// Clean up any messages that expired since last launch immediately
|
|
|
|
|
|
|
|
// and continue cleaning in the background.
|
|
|
|
RTCInitializeSSL();
|
|
|
|
[[OWSDisappearingMessagesJob sharedJob] startIfNecessary];
|
|
|
|
|
|
|
|
|
|
|
|
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
|
|
|
|
// Mark all "attempting out" messages as "unsent", i.e. any messages that were not successfully
|
|
|
|
accountManager:[Environment getCurrent].accountManager
|
|
|
|
// sent before the app exited should be marked as failures.
|
|
|
|
preferences:[Environment preferences]
|
|
|
|
[[[OWSFailedMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];
|
|
|
|
showAlerts:NO];
|
|
|
|
[[[OWSFailedAttachmentDownloadsJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];
|
|
|
|
|
|
|
|
|
|
|
|
// Clean up any messages that expired since last launch immediately
|
|
|
|
[AppStoreRating setupRatingLibrary];
|
|
|
|
// and continue cleaning in the background.
|
|
|
|
});
|
|
|
|
[[OWSDisappearingMessagesJob sharedJob] startIfNecessary];
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ running post launch block for unregistered user.", self.tag);
|
|
|
|
// Mark all "attempting out" messages as "unsent", i.e. any messages that were not successfully
|
|
|
|
|
|
|
|
// sent before the app exited should be marked as failures.
|
|
|
|
|
|
|
|
[[[OWSFailedMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run];
|
|
|
|
|
|
|
|
[[[OWSFailedAttachmentDownloadsJob alloc] initWithStorageManager:[TSStorageManager sharedManager]]
|
|
|
|
|
|
|
|
run];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[AppStoreRating setupRatingLibrary];
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[TSAccountManager sharedInstance]
|
|
|
|
|
|
|
|
ifRegistered:NO
|
|
|
|
|
|
|
|
runAsync:^{
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ running post launch block for unregistered user.", self.tag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Unregistered user should have no unread messages. e.g. if you delete your account.
|
|
|
|
|
|
|
|
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TSSocketManager requestSocketOpen];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UITapGestureRecognizer *gesture =
|
|
|
|
|
|
|
|
[[UITapGestureRecognizer alloc] initWithTarget:[Pastelog class]
|
|
|
|
|
|
|
|
action:@selector(submitLogs)];
|
|
|
|
|
|
|
|
gesture.numberOfTapsRequired = 8;
|
|
|
|
|
|
|
|
[self.window addGestureRecognizer:gesture];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
RTCInitializeSSL();
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[TSAccountManager sharedInstance]
|
|
|
|
// Unregistered user should have no unread messages. e.g. if you delete your account.
|
|
|
|
ifRegistered:YES
|
|
|
|
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
|
|
|
runAsync:^{
|
|
|
|
|
|
|
|
[TSSocketManager requestSocketOpen];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[TSSocketManager requestSocketOpen];
|
|
|
|
[[Environment getCurrent].contactsManager fetchSystemContactsIfAlreadyAuthorized];
|
|
|
|
|
|
|
|
});
|
|
|
|
UITapGestureRecognizer *gesture =
|
|
|
|
|
|
|
|
[[UITapGestureRecognizer alloc] initWithTarget:[Pastelog class] action:@selector(submitLogs)];
|
|
|
|
|
|
|
|
gesture.numberOfTapsRequired = 8;
|
|
|
|
|
|
|
|
[self.window addGestureRecognizer:gesture];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}); // end dispatchOnce for first time we become active
|
|
|
|
|
|
|
|
|
|
|
|
// This will fetch new messages, if we're using domain
|
|
|
|
// Every time we become active...
|
|
|
|
// fronting.
|
|
|
|
if ([TSAccountManager isRegistered]) {
|
|
|
|
[[PushManager sharedManager] applicationDidBecomeActive];
|
|
|
|
// At this point, potentially lengthy DB locking migrations could be running.
|
|
|
|
}];
|
|
|
|
// Avoid blocking app launch by putting all further possible DB access in async block
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
[TSSocketManager requestSocketOpen];
|
|
|
|
|
|
|
|
[[Environment getCurrent].contactsManager fetchSystemContactsIfAlreadyAuthorized];
|
|
|
|
|
|
|
|
// This will fetch new messages, if we're using domain fronting.
|
|
|
|
|
|
|
|
[[PushManager sharedManager] applicationDidBecomeActive];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.tag);
|
|
|
|
DDLogInfo(@"%@ applicationDidBecomeActive completed.", self.tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|