Clean up ahead of PR.

pull/1/head
Matthew Chen 7 years ago
parent 8c54297918
commit 055061ff5e

@ -38,6 +38,16 @@ NS_ASSUME_NONNULL_BEGIN
self.title = NSLocalizedString(@"ENABLE_2FA_VIEW_TITLE", @"Title for the 'enable two factor auth PIN' views.");
[self createContents];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(stateDidChange:)
name:NSNotificationName_2FAStateDidChange
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)createContents
@ -72,15 +82,8 @@ NS_ASSUME_NONNULL_BEGIN
[super viewWillAppear:animated];
if (self.mode == OWS2FASettingsMode_Status) {
// Ever time we re-enter the "status" view, recreate its
// contents wholesale since we may have just enabled or
// disabled 2FA.
[self createContents];
} else {
// If we're using a table, refresh its contents.
[self updateTableContents];
}
// If we're using a table, refresh its contents.
[self updateTableContents];
[self updateNavigationItems];
}
@ -413,7 +416,7 @@ NS_ASSUME_NONNULL_BEGIN
}
failure:^(NSError *error) {
[modalActivityIndicator dismissWithCompletion:^{
[weakSelf createContents];
[weakSelf updateTableContents];
[OWSAlerts
showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
@ -477,6 +480,15 @@ NS_ASSUME_NONNULL_BEGIN
[self.navigationController popViewControllerAnimated:YES];
}
- (void)stateDidChange:(NSNotification *)notification
{
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
if (self.mode == OWS2FASettingsMode_Status) {
[self createContents];
}
}
@end
NS_ASSUME_NONNULL_END

@ -4,6 +4,8 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *const NSNotificationName_2FAStateDidChange;
typedef void (^OWS2FASuccess)(void);
typedef void (^OWS2FAFailure)(NSError *error);

@ -3,6 +3,7 @@
//
#import "OWS2FAManager.h"
#import "NSNotificationCenter+OWS.h"
#import "OWSRequestFactory.h"
#import "TSNetworkManager.h"
#import "TSStorageManager.h"
@ -10,6 +11,8 @@
NS_ASSUME_NONNULL_BEGIN
NSString *const NSNotificationName_2FAStateDidChange = @"NSNotificationName_2FAStateDidChange";
NSString *const kOWS2FAManager_Collection = @"kOWS2FAManager_Collection";
NSString *const kOWS2FAManager_IsEnabledKey = @"kOWS2FAManager_IsEnabledKey";
@ -72,6 +75,10 @@ NSString *const kOWS2FAManager_IsEnabledKey = @"kOWS2FAManager_IsEnabledKey";
- (void)setIs2FAEnabled:(BOOL)value
{
[self.dbConnection setBool:value forKey:kOWS2FAManager_IsEnabledKey inCollection:kOWS2FAManager_Collection];
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationName_2FAStateDidChange
object:nil
userInfo:nil];
}
- (void)enable2FAWithPin:(NSString *)pin success:(nullable OWS2FASuccess)success failure:(nullable OWS2FAFailure)failure

Loading…
Cancel
Save