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 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;

@ -158,6 +158,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];
@ -168,6 +172,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