Add missing retains to promises.

pull/1/head
Matthew Chen 7 years ago
parent 222e07c5bd
commit 48bd0cfa06

@ -107,39 +107,40 @@ NS_ASSUME_NONNULL_BEGIN
canCancel:NO canCancel:NO
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]);
[self.accountManager registerObjcWithVerificationCode:self.verificationCode pin:pinCode] [[self.accountManager registerObjcWithVerificationCode:self.verificationCode pin:pinCode]
.then(^{ .then(^{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]);
[[OWS2FAManager sharedManager] mark2FAAsEnabledWithPin:pinCode]; [[OWS2FAManager sharedManager] mark2FAAsEnabledWithPin:pinCode];
OWSLogInfo(@"Successfully registered Signal account."); OWSLogInfo(@"Successfully registered Signal account.");
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[modalActivityIndicator dismissWithCompletion:^{ [modalActivityIndicator dismissWithCompletion:^{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[weakSelf verificationWasCompleted]; [weakSelf verificationWasCompleted];
}]; }];
}); });
}) })
.catch(^(NSError *error) { .catch(^(NSError *error) {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]);
OWSLogError(@"error verifying challenge: %@", error); OWSLogError(@"error verifying challenge: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[modalActivityIndicator dismissWithCompletion:^{ [modalActivityIndicator dismissWithCompletion:^{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[OWSAlerts showAlertWithTitle:NSLocalizedString( [OWSAlerts
@"REGISTER_2FA_REGISTRATION_FAILED_ALERT_TITLE", showAlertWithTitle:NSLocalizedString(
@"Title for alert indicating that attempt to " @"REGISTER_2FA_REGISTRATION_FAILED_ALERT_TITLE",
@"register with 'two-factor auth' failed.") @"Title for alert indicating that attempt to "
message:error.localizedDescription]; @"register with 'two-factor auth' failed.")
message:error.localizedDescription];
[weakSelf.entryView makePinTextFieldFirstResponder];
}]; [weakSelf.entryView makePinTextFieldFirstResponder];
}); }];
}); });
}) retainUntilComplete];
}]; }];
} }

@ -187,7 +187,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
[OWSBackup.sharedManager setIsBackupEnabled:YES]; [OWSBackup.sharedManager setIsBackupEnabled:YES];
}) })
.thenInBackground(^{ .thenInBackground(^{
[self.tsAccountManager updateAccountAttributes]; [[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
[self succeed]; [self succeed];
}); });

@ -33,7 +33,7 @@ public class OWS111UDAttributesMigration: OWSDatabaseMigration {
} }
private func doMigration() { private func doMigration() {
tsAccountManager.updateAccountAttributes() tsAccountManager.updateAccountAttributes().retainUntilComplete()
self.dbReadWriteConnection().readWrite { transaction in self.dbReadWriteConnection().readWrite { transaction in
self.save(with: transaction) self.save(with: transaction)

@ -860,7 +860,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
{ {
OWSUserProfile *userProfile = self.localUserProfile; OWSUserProfile *userProfile = self.localUserProfile;
[userProfile clearWithProfileKey:[OWSAES256Key generateRandomKey] dbConnection:self.dbConnection completion:nil]; [userProfile clearWithProfileKey:[OWSAES256Key generateRandomKey] dbConnection:self.dbConnection completion:nil];
[self.tsAccountManager updateAccountAttributes]; [[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
} }
- (void)addUserToProfileWhitelist:(NSString *)recipientId - (void)addUserToProfileWhitelist:(NSString *)recipientId

@ -86,7 +86,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
} }
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
[self updateAccountAttributesIfNecessary]; [[self updateAccountAttributesIfNecessary] retainUntilComplete];
}]; }];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
@ -721,7 +721,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[AppReadiness runNowOrWhenAppDidBecomeReady:^{ [AppReadiness runNowOrWhenAppDidBecomeReady:^{
[self updateAccountAttributesIfNecessary]; [[self updateAccountAttributesIfNecessary] retainUntilComplete];
}]; }];
} }

@ -485,6 +485,6 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
dbConnection.setBool(value, forKey: kUDUnrestrictedAccessKey, inCollection: kUDCollection) dbConnection.setBool(value, forKey: kUDUnrestrictedAccessKey, inCollection: kUDCollection)
// Try to update the account attributes to reflect this change. // Try to update the account attributes to reflect this change.
tsAccountManager.updateAccountAttributes() tsAccountManager.updateAccountAttributes().retainUntilComplete()
} }
} }

@ -10,6 +10,7 @@
#import "TSAccountManager.h" #import "TSAccountManager.h"
#import "TSNetworkManager.h" #import "TSNetworkManager.h"
#import "YapDatabaseConnection+OWS.h" #import "YapDatabaseConnection+OWS.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -89,7 +90,7 @@ const NSUInteger kDaySecs = kHourSecs * 24;
object:nil object:nil
userInfo:nil]; userInfo:nil];
[self.tsAccountManager updateAccountAttributes]; [[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
} }
- (void)mark2FAAsEnabledWithPin:(NSString *)pin - (void)mark2FAAsEnabledWithPin:(NSString *)pin
@ -105,7 +106,7 @@ const NSUInteger kDaySecs = kHourSecs * 24;
object:nil object:nil
userInfo:nil]; userInfo:nil];
[self.tsAccountManager updateAccountAttributes]; [[self.tsAccountManager updateAccountAttributes] retainUntilComplete];
} }
- (void)requestEnable2FAWithPin:(NSString *)pin - (void)requestEnable2FAWithPin:(NSString *)pin

Loading…
Cancel
Save