Merge pull request #70 from loki-project/clear-all-data-fix

Use signal implementation of reset data
pull/74/head
gmbnt 5 years ago committed by GitHub
commit f15fdcd128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1638,22 +1638,12 @@ static NSTimeInterval launchStartedAt;
[self stopLongPollerIfNeeded];
[self.lokiNewsFeedPoller stop];
[self.lokiMessengerUpdatesFeedPoller stop];
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction removeAllObjectsInCollection:LKPublicChatAPI.lastMessageServerIDCollection];
[transaction removeAllObjectsInCollection:LKPublicChatAPI.lastDeletionServerIDCollection];
[transaction removeAllObjectsInCollection:@"LKMessageIDCollection"];
[transaction removeAllObjectsInCollection:@"LKLastMessageHashCollection"];
NSDictionary<NSString *, LKPublicChat *> *allPublicChats = [LKDatabaseUtilities getAllPublicChats:transaction];
for (NSString *threadID in allPublicChats.allKeys) {
[LKDatabaseUtilities removePublicChatForThreadID:threadID transaction:transaction];
}
}];
[LKPublicChatManager.shared stopPollers];
[SSKEnvironment.shared.tsAccountManager resetForReregistration];
UIViewController *rootVC = [OnboardingController new].initialViewController;
OWSNavigationController *navigationVC = [[OWSNavigationController alloc] initWithRootViewController:rootVC];
[navigationVC setNavigationBarHidden:YES];
UIApplication.sharedApplication.keyWindow.rootViewController = navigationVC;
bool wasUnlinked = [NSUserDefaults.standardUserDefaults boolForKey:@"wasUnlinked"];
[SignalApp resetAppData:^{
// Resetting the data clears the old user defaults. We need to restore the unlink default.
[NSUserDefaults.standardUserDefaults setBool:wasUnlinked forKey:@"wasUnlinked"];
}];
}
@end

@ -51,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Methods
+ (void)resetAppData;
+ (void)resetAppData:(void (^__nullable)(void))onReset;
- (void)showHomeView;

@ -158,6 +158,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)resetAppData
{
[self resetAppData:nil];
}
+ (void)resetAppData:(void (^__nullable)(void))onReset {
// This _should_ be wiped out below.
OWSLogError(@"");
[DDLog flushLog];
@ -168,6 +172,7 @@ NS_ASSUME_NONNULL_BEGIN
[AppEnvironment.shared.notificationPresenter clearAllNotifications];
[DebugLogger.sharedLogger wipeLogs];
if(onReset != nil) { onReset(); }
exit(0);
}

Loading…
Cancel
Save