From 27e496ad06593cdd17f12af60945286c7dbabbee Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 18 Aug 2017 10:11:37 -0400 Subject: [PATCH] Respond to CR. // FREEBIE --- .../src/ViewControllers/ProfileViewController.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index b48343bc9..eb14108f8 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -46,8 +46,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat @property (nonatomic) ProfileViewMode profileViewMode; -@property (nonatomic) YapDatabaseConnection *databaseConnection; - @end #pragma mark - @@ -63,11 +61,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat } self.profileViewMode = profileViewMode; - self.databaseConnection = [[TSStorageManager sharedManager] newDatabaseConnection]; - [self.databaseConnection setDate:[NSDate new] - forKey:kProfileView_LastPresentedDate - inCollection:kProfileView_Collection]; + // Use the TSStorageManager.dbReadWriteConnection for consistency with the reads below. + [[[TSStorageManager sharedManager] dbReadWriteConnection] setDate:[NSDate new] + forKey:kProfileView_LastPresentedDate + inCollection:kProfileView_Collection]; return self; } @@ -421,10 +419,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat return NO; } + // Use the TSStorageManager.dbReadWriteConnection for consistency with the writes above. NSTimeInterval kProfileNagFrequency = kDayInterval * 30; NSDate *_Nullable lastPresentedDate = - [[[TSStorageManager sharedManager] dbReadConnection] dateForKey:kProfileView_LastPresentedDate - inCollection:kProfileView_Collection]; + [[[TSStorageManager sharedManager] dbReadWriteConnection] dateForKey:kProfileView_LastPresentedDate + inCollection:kProfileView_Collection]; return (!lastPresentedDate || fabs([lastPresentedDate timeIntervalSinceNow]) > kProfileNagFrequency); }