Clean up usage of TSAccountManager.

pull/1/head
Matthew Chen 6 years ago
parent d44a8f9996
commit 8110e0c765

@ -25,7 +25,7 @@ public class AccountManager: NSObject {
SwiftSingletons.register(self) SwiftSingletons.register(self)
} }
// MARK: - Singletons // MARK: - Dependencies
private var networkManager: TSNetworkManager { private var networkManager: TSNetworkManager {
return SSKEnvironment.shared.networkManager return SSKEnvironment.shared.networkManager

@ -38,6 +38,17 @@ NS_ASSUME_NONNULL_BEGIN
@implementation CodeVerificationViewController @implementation CodeVerificationViewController
#pragma mark - Dependencies
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
{ {
self = [super initWithCoder:aDecoder]; self = [super initWithCoder:aDecoder];
@ -352,7 +363,7 @@ NS_ASSUME_NONNULL_BEGIN
[_requestCodeAgainSpinner startAnimating]; [_requestCodeAgainSpinner startAnimating];
__weak CodeVerificationViewController *weakSelf = self; __weak CodeVerificationViewController *weakSelf = self;
[TSAccountManager [self.tsAccountManager
rerequestSMSWithSuccess:^{ rerequestSMSWithSuccess:^{
OWSLogInfo(@"Successfully requested SMS code"); OWSLogInfo(@"Successfully requested SMS code");
[weakSelf enableServerActions:YES]; [weakSelf enableServerActions:YES];
@ -375,7 +386,7 @@ NS_ASSUME_NONNULL_BEGIN
[_requestCallSpinner startAnimating]; [_requestCallSpinner startAnimating];
__weak CodeVerificationViewController *weakSelf = self; __weak CodeVerificationViewController *weakSelf = self;
[TSAccountManager [self.tsAccountManager
rerequestVoiceWithSuccess:^{ rerequestVoiceWithSuccess:^{
OWSLogInfo(@"Successfully requested voice code"); OWSLogInfo(@"Successfully requested voice code");

@ -43,6 +43,17 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
@implementation RegistrationViewController @implementation RegistrationViewController
#pragma mark - Dependencies
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
- (void)loadView - (void)loadView
{ {
[super loadView]; [super loadView];
@ -287,10 +298,10 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[self.spinnerView stopAnimating]; [self.spinnerView stopAnimating];
[self.phoneNumberTextField becomeFirstResponder]; [self.phoneNumberTextField becomeFirstResponder];
if ([TSAccountManager sharedInstance].isReregistering) { if (self.tsAccountManager.isReregistering) {
// If re-registering, pre-populate the country (country code, calling code, country name) // If re-registering, pre-populate the country (country code, calling code, country name)
// and phone number state. // and phone number state.
NSString *_Nullable phoneNumberE164 = [TSAccountManager sharedInstance].reregisterationPhoneNumber; NSString *_Nullable phoneNumberE164 = self.tsAccountManager.reregisterationPhoneNumber;
if (!phoneNumberE164) { if (!phoneNumberE164) {
OWSFailDebug(@"Could not resume re-registration; missing phone number."); OWSFailDebug(@"Could not resume re-registration; missing phone number.");
} else if ([self tryToApplyPhoneNumberE164:phoneNumberE164]) { } else if ([self tryToApplyPhoneNumberE164:phoneNumberE164]) {
@ -441,7 +452,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[self.phoneNumberTextField resignFirstResponder]; [self.phoneNumberTextField resignFirstResponder];
__weak RegistrationViewController *weakSelf = self; __weak RegistrationViewController *weakSelf = self;
[TSAccountManager registerWithPhoneNumber:parsedPhoneNumber [self.tsAccountManager registerWithPhoneNumber:parsedPhoneNumber
success:^{ success:^{
OWSProdInfo([OWSAnalyticsEvents registrationRegisteredPhoneNumber]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteredPhoneNumber]);
@ -472,7 +483,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (void)countryCodeRowWasTapped:(UIGestureRecognizer *)sender - (void)countryCodeRowWasTapped:(UIGestureRecognizer *)sender
{ {
if (TSAccountManager.sharedInstance.isReregistering) { if (self.tsAccountManager.isReregistering) {
// Don't let user edit their phone number while re-registering. // Don't let user edit their phone number while re-registering.
return; return;
} }

@ -148,6 +148,13 @@ NSString *NSStringForBackupImportState(OWSBackupState state)
return SSKEnvironment.shared.primaryStorage; return SSKEnvironment.shared.primaryStorage;
} }
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - Backup Export #pragma mark - Backup Export
- (void)tryToExportBackup - (void)tryToExportBackup
@ -270,7 +277,7 @@ NSString *NSStringForBackupImportState(OWSBackupState state)
// Don't start backups when app is in the background. // Don't start backups when app is in the background.
return NO; return NO;
} }
if (![TSAccountManager isRegistered]) { if (![self.tsAccountManager isRegistered]) {
return NO; return NO;
} }
return YES; return YES;

@ -290,6 +290,13 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
return SSKEnvironment.shared.primaryStorage.dbReadWriteConnection; return SSKEnvironment.shared.primaryStorage.dbReadWriteConnection;
} }
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - #pragma mark -
+ (void)submitLogs + (void)submitLogs
@ -570,7 +577,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)sendToSelf:(NSURL *)url - (void)sendToSelf:(NSURL *)url
{ {
if (![TSAccountManager isRegistered]) { if (![self.tsAccountManager isRegistered]) {
return; return;
} }
NSString *recipientId = [TSAccountManager localNumber]; NSString *recipientId = [TSAccountManager localNumber];
@ -594,7 +601,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)sendToMostRecentThread:(NSURL *)url - (void)sendToMostRecentThread:(NSURL *)url
{ {
if (![TSAccountManager isRegistered]) { if (![self.tsAccountManager isRegistered]) {
return; return;
} }

@ -14,6 +14,17 @@ NS_ASSUME_NONNULL_BEGIN
@implementation RegistrationUtils @implementation RegistrationUtils
#pragma mark - Dependencies
+ (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
+ (void)showReregistrationUIFromViewController:(UIViewController *)fromViewController + (void)showReregistrationUIFromViewController:(UIViewController *)fromViewController
{ {
UIAlertController *actionSheetController = UIAlertController *actionSheetController =
@ -37,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSLogInfo(@"reregisterWithSamePhoneNumber."); OWSLogInfo(@"reregisterWithSamePhoneNumber.");
if (![[TSAccountManager sharedInstance] resetForReregistration]) { if (![self.tsAccountManager resetForReregistration]) {
OWSFailDebug(@"could not reset for re-registration."); OWSFailDebug(@"could not reset for re-registration.");
return; return;
} }
@ -48,8 +59,8 @@ NS_ASSUME_NONNULL_BEGIN
presentFromViewController:fromViewController presentFromViewController:fromViewController
canCancel:NO canCancel:NO
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
[TSAccountManager [self.tsAccountManager
registerWithPhoneNumber:[TSAccountManager sharedInstance].reregisterationPhoneNumber registerWithPhoneNumber:self.tsAccountManager.reregisterationPhoneNumber
success:^{ success:^{
OWSLogInfo(@"re-registering: send verification code succeeded."); OWSLogInfo(@"re-registering: send verification code succeeded.");

@ -215,7 +215,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
- (void)sendConfigurationSyncMessage { - (void)sendConfigurationSyncMessage {
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
if (!TSAccountManager.isRegistered) { if (!self.tsAccountManager.isRegistered) {
return; return;
} }

@ -30,7 +30,16 @@ NS_ASSUME_NONNULL_BEGIN
@implementation VersionMigrations @implementation VersionMigrations
#pragma mark Utility methods #pragma mark - Dependencies
+ (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - Utility methods
+ (void)performUpdateCheckWithCompletion:(VersionMigrationCompletion)completion + (void)performUpdateCheckWithCompletion:(VersionMigrationCompletion)completion
{ {
@ -76,12 +85,12 @@ NS_ASSUME_NONNULL_BEGIN
[CurrentAppContext().frontmostViewController presentViewController:alertController animated:YES completion:nil]; [CurrentAppContext().frontmostViewController presentViewController:alertController animated:YES completion:nil];
} }
if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [TSAccountManager isRegistered]) { if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [self.tsAccountManager isRegistered]) {
[self clearVideoCache]; [self clearVideoCache];
[self blockingAttributesUpdate]; [self blockingAttributesUpdate];
} }
if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.3.0"] && [TSAccountManager isRegistered]) { if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.3.0"] && [self.tsAccountManager isRegistered]) {
[self clearBloomFilterCache]; [self clearBloomFilterCache];
} }

@ -4,6 +4,7 @@
#import "OWS103EnableVideoCalling.h" #import "OWS103EnableVideoCalling.h"
#import <SignalServiceKit/OWSRequestFactory.h> #import <SignalServiceKit/OWSRequestFactory.h>
#import <SignalServiceKit/SSKEnvironment.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSNetworkManager.h> #import <SignalServiceKit/TSNetworkManager.h>
@ -12,6 +13,17 @@ static NSString *const OWS103EnableVideoCallingMigrationId = @"103";
@implementation OWS103EnableVideoCalling @implementation OWS103EnableVideoCalling
#pragma mark - Dependencies
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
+ (NSString *)migrationId + (NSString *)migrationId
{ {
return OWS103EnableVideoCallingMigrationId; return OWS103EnableVideoCallingMigrationId;
@ -23,7 +35,7 @@ static NSString *const OWS103EnableVideoCallingMigrationId = @"103";
OWSAssertDebug(completion); OWSAssertDebug(completion);
OWSLogWarn(@"running migration..."); OWSLogWarn(@"running migration...");
if ([TSAccountManager isRegistered]) { if ([self.tsAccountManager isRegistered]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
TSRequest *request = [OWSRequestFactory updateAttributesRequest]; TSRequest *request = [OWSRequestFactory updateAttributesRequest];
[[TSNetworkManager sharedManager] makeRequest:request [[TSNetworkManager sharedManager] makeRequest:request

@ -44,6 +44,14 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
*/ */
private class CompleteRegistrationFixerJob: NSObject { private class CompleteRegistrationFixerJob: NSObject {
// MARK: - Dependencies
private var tsAccountManager: TSAccountManager {
return TSAccountManager.sharedInstance()
}
// MARK: -
// Duration between retries if update fails. // Duration between retries if update fails.
let kRetryInterval: TimeInterval = 5 let kRetryInterval: TimeInterval = 5
@ -54,7 +62,7 @@ public class OWS106EnsureProfileComplete: OWSDatabaseMigration {
} }
func start() { func start() {
guard TSAccountManager.isRegistered() else { guard tsAccountManager.isRegistered() else {
self.completionHandler(true) self.completionHandler(true)
return return
} }

@ -105,6 +105,13 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
return SSKEnvironment.shared.syncManager; return SSKEnvironment.shared.syncManager;
} }
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - #pragma mark -
- (nullable NSString *)avatarUrlPath - (nullable NSString *)avatarUrlPath
@ -219,7 +226,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
// We populate an initial (empty) profile on launch of a new install, but until // We populate an initial (empty) profile on launch of a new install, but until
// we have a registered account, syncing will fail (and there could not be any // we have a registered account, syncing will fail (and there could not be any
// linked device to sync to at this point anyway). // linked device to sync to at this point anyway).
if ([TSAccountManager isRegistered] && CurrentAppContext().isMainApp) { if ([self.tsAccountManager isRegistered] && CurrentAppContext().isMainApp) {
[self.syncManager syncLocalContact]; [self.syncManager syncLocalContact];
} }

@ -17,6 +17,12 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange;
@class TSNetworkManager; @class TSNetworkManager;
@class YapDatabaseReadWriteTransaction; @class YapDatabaseReadWriteTransaction;
typedef NS_ENUM(NSUInteger, OWSRegistrationState) {
OWSRegistrationState_Unregistered,
OWSRegistrationState_PendingBackupRestore,
OWSRegistrationState_Registered,
};
@interface TSAccountManager : NSObject @interface TSAccountManager : NSObject
// This property is exposed for testing purposes only. // This property is exposed for testing purposes only.
@ -37,7 +43,6 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange;
* *
* @return registered or not * @return registered or not
*/ */
+ (BOOL)isRegistered;
- (BOOL)isRegistered; - (BOOL)isRegistered;
/** /**
@ -76,14 +81,14 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange;
#pragma mark - Register with phone number #pragma mark - Register with phone number
+ (void)registerWithPhoneNumber:(NSString *)phoneNumber - (void)registerWithPhoneNumber:(NSString *)phoneNumber
success:(void (^)(void))successBlock success:(void (^)(void))successBlock
failure:(void (^)(NSError *error))failureBlock failure:(void (^)(NSError *error))failureBlock
smsVerification:(BOOL)isSMS; smsVerification:(BOOL)isSMS;
+ (void)rerequestSMSWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock; - (void)rerequestSMSWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock;
+ (void)rerequestVoiceWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock; - (void)rerequestVoiceWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock;
- (void)verifyAccountWithCode:(NSString *)verificationCode - (void)verifyAccountWithCode:(NSString *)verificationCode
pin:(nullable NSString *)pin pin:(nullable NSString *)pin

@ -135,11 +135,6 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
userInfo:nil]; userInfo:nil];
} }
+ (BOOL)isRegistered
{
return [[self sharedInstance] isRegistered];
}
- (BOOL)isRegistered - (BOOL)isRegistered
{ {
@synchronized (self) { @synchronized (self) {
@ -294,7 +289,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
}]; }];
} }
+ (void)registerWithPhoneNumber:(NSString *)phoneNumber - (void)registerWithPhoneNumber:(NSString *)phoneNumber
success:(void (^)(void))successBlock success:(void (^)(void))successBlock
failure:(void (^)(NSError *error))failureBlock failure:(void (^)(NSError *error))failureBlock
smsVerification:(BOOL)isSMS smsVerification:(BOOL)isSMS
@ -308,8 +303,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
// The country code of TSAccountManager.phoneNumberAwaitingVerification is used to // The country code of TSAccountManager.phoneNumberAwaitingVerification is used to
// determine whether or not to use domain fronting, so it needs to be set _before_ // determine whether or not to use domain fronting, so it needs to be set _before_
// we make our verification code request. // we make our verification code request.
TSAccountManager *manager = [self sharedInstance]; self.phoneNumberAwaitingVerification = phoneNumber;
manager.phoneNumberAwaitingVerification = phoneNumber;
TSRequest *request = TSRequest *request =
[OWSRequestFactory requestVerificationCodeRequestWithPhoneNumber:phoneNumber [OWSRequestFactory requestVerificationCodeRequestWithPhoneNumber:phoneNumber
@ -331,21 +325,17 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
}]; }];
} }
+ (void)rerequestSMSWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock - (void)rerequestSMSWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock
{ {
TSAccountManager *manager = [self sharedInstance]; NSString *number = self.phoneNumberAwaitingVerification;
NSString *number = manager.phoneNumberAwaitingVerification;
OWSAssertDebug(number); OWSAssertDebug(number);
[self registerWithPhoneNumber:number success:successBlock failure:failureBlock smsVerification:YES]; [self registerWithPhoneNumber:number success:successBlock failure:failureBlock smsVerification:YES];
} }
+ (void)rerequestVoiceWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock - (void)rerequestVoiceWithSuccess:(void (^)(void))successBlock failure:(void (^)(NSError *error))failureBlock
{ {
TSAccountManager *manager = [self sharedInstance]; NSString *number = self.phoneNumberAwaitingVerification;
NSString *number = manager.phoneNumberAwaitingVerification;
OWSAssertDebug(number); OWSAssertDebug(number);
[self registerWithPhoneNumber:number success:successBlock failure:failureBlock smsVerification:NO]; [self registerWithPhoneNumber:number success:successBlock failure:failureBlock smsVerification:NO];

@ -7,6 +7,7 @@
#import "NSURLSessionDataTask+StatusCode.h" #import "NSURLSessionDataTask+StatusCode.h"
#import "OWSIdentityManager.h" #import "OWSIdentityManager.h"
#import "OWSPrimaryStorage+SignedPreKeyStore.h" #import "OWSPrimaryStorage+SignedPreKeyStore.h"
#import "SSKEnvironment.h"
#import "TSNetworkManager.h" #import "TSNetworkManager.h"
#import "TSStorageHeaders.h" #import "TSStorageHeaders.h"
#import <SignalCoreKit/NSDate+OWS.h> #import <SignalCoreKit/NSDate+OWS.h>
@ -36,6 +37,15 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
@implementation TSPreKeyManager @implementation TSPreKeyManager
#pragma mark - Dependencies
+ (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - State Tracking #pragma mark - State Tracking
+ (BOOL)isAppLockedDueToPreKeyUpdateFailures + (BOOL)isAppLockedDueToPreKeyUpdateFailures
@ -102,7 +112,7 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
} }
OWSAssertDebug(CurrentAppContext().isMainAppAndActive); OWSAssertDebug(CurrentAppContext().isMainAppAndActive);
if (!TSAccountManager.isRegistered) { if (!self.tsAccountManager.isRegistered) {
return; return;
} }

@ -131,6 +131,13 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
return SSKEnvironment.shared.udManager; return SSKEnvironment.shared.udManager;
} }
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark - Blocking #pragma mark - Blocking
- (BOOL)isEnvelopeSenderBlocked:(SSKProtoEnvelope *)envelope - (BOOL)isEnvelopeSenderBlocked:(SSKProtoEnvelope *)envelope
@ -140,11 +147,6 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
return [self.blockingManager.blockedPhoneNumbers containsObject:envelope.source]; return [self.blockingManager.blockedPhoneNumbers containsObject:envelope.source];
} }
- (TSAccountManager *)tsAccountManager
{
return TSAccountManager.sharedInstance;
}
#pragma mark - Decryption #pragma mark - Decryption
- (void)decryptEnvelope:(SSKProtoEnvelope *)envelope - (void)decryptEnvelope:(SSKProtoEnvelope *)envelope
@ -156,7 +158,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
OWSAssertDebug(envelopeData); OWSAssertDebug(envelopeData);
OWSAssertDebug(successBlockParameter); OWSAssertDebug(successBlockParameter);
OWSAssertDebug(failureBlockParameter); OWSAssertDebug(failureBlockParameter);
OWSAssertDebug([TSAccountManager isRegistered]); OWSAssertDebug([self.tsAccountManager isRegistered]);
// successBlock is called synchronously so that we can avail ourselves of // successBlock is called synchronously so that we can avail ourselves of
// the transaction. // the transaction.

@ -236,7 +236,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSFail(@"Missing transaction."); OWSFail(@"Missing transaction.");
return; return;
} }
if (!TSAccountManager.isRegistered) { if (!self.tsAccountManager.isRegistered) {
OWSFailDebug(@"Not registered."); OWSFailDebug(@"Not registered.");
return; return;
} }

@ -123,7 +123,7 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
@objc public func setup() { @objc public func setup() {
AppReadiness.runNowOrWhenAppDidBecomeReady { AppReadiness.runNowOrWhenAppDidBecomeReady {
guard TSAccountManager.isRegistered() else { guard self.tsAccountManager.isRegistered() else {
return return
} }

@ -912,7 +912,7 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O
return NO; return NO;
} }
if (![TSAccountManager isRegistered]) { if (![self.tsAccountManager isRegistered]) {
return NO; return NO;
} }

@ -12,6 +12,14 @@ import PromiseKit
@objc @objc
public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailedViewDelegate { public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailedViewDelegate {
// MARK: - Dependencies
private var tsAccountManager: TSAccountManager {
return TSAccountManager.sharedInstance()
}
// MARK: -
enum ShareViewControllerError: Error { enum ShareViewControllerError: Error {
case assertionError(description: String) case assertionError(description: String)
case unsupportedMedia case unsupportedMedia
@ -171,7 +179,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use RTCInitializeSSL() in the SAE. // We don't need to use RTCInitializeSSL() in the SAE.
if TSAccountManager.isRegistered() { if tsAccountManager.isRegistered() {
// At this point, potentially lengthy DB locking migrations could be running. // 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 // Avoid blocking app launch by putting all further possible DB access in async block
DispatchQueue.global().async { [weak self] in DispatchQueue.global().async { [weak self] in
@ -192,7 +200,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to prod the TSSocketManager in the SAE. // We don't need to prod the TSSocketManager in the SAE.
} }
if TSAccountManager.isRegistered() { if tsAccountManager.isRegistered() {
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
guard let _ = self else { return } guard let _ = self else { return }
Logger.info("running post launch block for registered user: \(TSAccountManager.localNumber)") Logger.info("running post launch block for registered user: \(TSAccountManager.localNumber)")
@ -253,7 +261,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// it will also run all deferred blocks. // it will also run all deferred blocks.
AppReadiness.setAppIsReady() AppReadiness.setAppIsReady()
if TSAccountManager.isRegistered() { if tsAccountManager.isRegistered() {
Logger.info("localNumber: \(TSAccountManager.localNumber)") Logger.info("localNumber: \(TSAccountManager.localNumber)")
// We don't need to use messageFetcherJob in the SAE. // We don't need to use messageFetcherJob in the SAE.
@ -285,7 +293,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
Logger.debug("") Logger.debug("")
if TSAccountManager.isRegistered() { if tsAccountManager.isRegistered() {
Logger.info("localNumber: \(TSAccountManager.localNumber)") Logger.info("localNumber: \(TSAccountManager.localNumber)")
// We don't need to use ExperienceUpgradeFinder in the SAE. // We don't need to use ExperienceUpgradeFinder in the SAE.
@ -325,7 +333,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
Logger.info("Presenting content view") Logger.info("Presenting content view")
if !TSAccountManager.isRegistered() { if !tsAccountManager.isRegistered() {
showNotRegisteredView() showNotRegisteredView()
} else if !OWSProfileManager.shared().localProfileExists() { } else if !OWSProfileManager.shared().localProfileExists() {
// This is a rare edge case, but we want to ensure that the user // This is a rare edge case, but we want to ensure that the user
@ -451,7 +459,7 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// If a user unregisters in the main app, the SAE should shut down // If a user unregisters in the main app, the SAE should shut down
// immediately. // immediately.
guard !TSAccountManager.isRegistered() else { guard !tsAccountManager.isRegistered() else {
// If user is registered, do nothing. // If user is registered, do nothing.
return return
} }

Loading…
Cancel
Save