diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index e4f1ed3d3..d84ad59fb 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -159,6 +159,10 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; selector:@selector(databaseViewRegistrationComplete) name:kNSNotificationName_DatabaseViewRegistrationComplete object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(registrationStateDidChange) + name:kNSNotificationName_RegistrationStateDidChange + object:nil]; DDLogInfo(@"%@ application: didFinishLaunchingWithOptions completed.", self.tag); @@ -792,6 +796,26 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; [OWSProfileManager.sharedManager fetchLocalUsersProfile]; } +- (void)registrationStateDidChange +{ + OWSAssert([NSThread isMainThread]); + + DDLogInfo(@"registrationStateDidChange"); + + if ([TSAccountManager isRegistered]) { + DDLogInfo(@"localNumber: %@", [TSAccountManager localNumber]); + + [[TSStorageManager sharedManager].newDatabaseConnection + readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + [[ExperienceUpgradeFinder new] markAllAsSeenWithTransaction:transaction]; + }]; + // Start running the disappearing messages job in case the newly registered user + // enables this feature + [[OWSDisappearingMessagesJob sharedJob] startIfNecessary]; + [[OWSProfileManager sharedManager] ensureLocalProfileCached]; + } +} + - (void)ensureRootViewController { DDLogInfo(@"ensureRootViewController"); diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index 6b244e04e..e45432411 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -492,15 +492,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; { [super viewDidAppear:animated]; - if (self.newlyRegisteredUser) { - [self.editingDbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [self.experienceUpgradeFinder markAllAsSeenWithTransaction:transaction]; - }]; - // Start running the disappearing messages job in case the newly registered user - // enables this feature - [[OWSDisappearingMessagesJob sharedJob] startIfNecessary]; - [[OWSProfileManager sharedManager] ensureLocalProfileCached]; - } else if (!self.viewHasEverAppeared) { + if (!self.newlyRegisteredUser && !self.viewHasEverAppeared) { [self displayAnyUnseenUpgradeExperience]; }