Use signal implementation of reset.

pull/70/head
Mikunj 6 years ago
parent abc6e20207
commit 5dfefbf739

@ -1620,22 +1620,12 @@ static NSTimeInterval launchStartedAt;
[self stopLongPollerIfNeeded]; [self stopLongPollerIfNeeded];
[self.lokiNewsFeedPoller stop]; [self.lokiNewsFeedPoller stop];
[self.lokiMessengerUpdatesFeedPoller 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]; [LKPublicChatManager.shared stopPollers];
[SSKEnvironment.shared.tsAccountManager resetForReregistration]; bool wasUnlinked = [NSUserDefaults.standardUserDefaults boolForKey:@"wasUnlinked"];
UIViewController *rootVC = [OnboardingController new].initialViewController; [SignalApp resetAppData:^{
OWSNavigationController *navigationVC = [[OWSNavigationController alloc] initWithRootViewController:rootVC]; // Resetting the data clears the old user defaults. We need to restore the unlink default.
[navigationVC setNavigationBarHidden:YES]; [NSUserDefaults.standardUserDefaults setBool:wasUnlinked forKey:@"wasUnlinked"];
UIApplication.sharedApplication.keyWindow.rootViewController = navigationVC; }];
} }
@end @end

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

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

Loading…
Cancel
Save