Add clear all data option to settings

pull/35/head
Niels Andriesse 6 years ago
parent 7d1bd3941f
commit a9b7663320

@ -249,6 +249,12 @@
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"show_seed")
selector:@selector(showSeed)
color:[UIColor ows_materialBlueColor]]];
[section
addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"Clear All Data", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"clear_all_data")
selector:@selector(clearAllData)
color:[UIColor ows_destructiveRedColor]]];
if (TSAccountManager.sharedInstance.isDeregistered) {
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON",
@ -522,6 +528,25 @@
[self presentAlert:alert];
}
- (void)clearAllData
{
NSString *title = NSLocalizedString(@"Clear All Data", @"");
NSString *message = NSLocalizedString(@"Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair.", @"");
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[ThreadUtil deleteAllContent];
[SSKEnvironment.shared.identityManager clearIdentityKey];
[LKAPI clearRandomSnodePool];
[LKAPI stopLongPolling];
UIViewController *rootViewController = [[OnboardingController new] initialViewController];
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:rootViewController];
navigationController.navigationBarHidden = YES;
UIApplication.sharedApplication.keyWindow.rootViewController = navigationController;
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { /* Do nothing */ }]];
[self presentAlert:alert];
}
- (void)reregisterUser
{
[RegistrationUtils showReregistrationUIFromViewController:self];

@ -2600,3 +2600,6 @@
"Looks like you don't have any conversations yet. Get started by messaging a friend." = "Looks like you don't have any conversations yet. Get started by messaging a friend.";
"Enter the public key of the person you'd like to securely message. They can share their public key with you by going into Loki Messenger's in-app settings and clicking \"Share Public Key\"." = "Enter the public key of the person you'd like to securely message. They can share their public key with you by going into Loki Messenger's in-app settings and clicking \"Share Public Key\".";
"Unlock Loki Messenger" = "Unlock Loki Messenger";
"Clear All Data" = "Clear All Data";
"Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair." = "Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair.";
"Cancel" = "Cancel";

@ -41,6 +41,10 @@ public extension LokiAPI {
// MARK: Clearnet Setup
fileprivate static let seedNodePool: Set<String> = [ "http://3.104.19.14:22023", "http://13.238.53.205:38157", "http://imaginary.stream:38157" ]
fileprivate static var randomSnodePool: Set<LokiAPITarget> = []
@objc public static func clearRandomSnodePool() {
randomSnodePool.removeAll()
}
// MARK: Internal API
private static func getRandomSnode() -> Promise<LokiAPITarget> {

@ -36,6 +36,7 @@ extern const NSUInteger kStoredIdentityKeyLength;
+ (instancetype)sharedManager;
- (void)generateNewIdentityKey;
- (void)clearIdentityKey;
- (void)setVerificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey

@ -124,6 +124,12 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
inCollection:OWSPrimaryStorageIdentityKeyStoreCollection];
}
- (void)clearIdentityKey
{
[self.dbConnection removeObjectForKey:OWSPrimaryStorageIdentityKeyStoreIdentityKey
inCollection:OWSPrimaryStorageIdentityKeyStoreCollection];
}
- (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId
{
__block NSData *_Nullable result = nil;

Loading…
Cancel
Save