From 9471f24cf38519a74f46fa7c45acc96c11ac02d2 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 19 Feb 2019 17:20:07 -0500 Subject: [PATCH 1/5] Introduce ConversationSnapshot. --- .../ConversationViewController.m | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index a40183cd2..891f994c2 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -108,6 +108,25 @@ typedef enum : NSUInteger { #pragma mark - +// We use snapshots to ensure that the view has a consistent +// representation of view model state which is not updated +// when the view is not observing view model changes. +@interface ConversationSnapshot : NSObject + +@property (nonatomic) NSArray> *viewItems; +@property (nonatomic) ThreadDynamicInteractions *dynamicInteractions; +@property (nonatomic) BOOL canLoadMoreItems; + +@end + +#pragma mark - + +@implementation ConversationSnapshot + +@end + +#pragma mark - + @interface ConversationViewController () > *)viewItems { - return self.conversationViewModel.viewItems; + return self.conversationSnapshot.viewItems; } - (ThreadDynamicInteractions *)dynamicInteractions { - return self.conversationViewModel.dynamicInteractions; + return self.conversationSnapshot.dynamicInteractions; } - (NSIndexPath *_Nullable)indexPathOfUnreadMessagesIndicator @@ -1696,7 +1718,7 @@ typedef enum : NSUInteger { { OWSAssertDebug(self.conversationViewModel); - self.showLoadMoreHeader = self.conversationViewModel.canLoadMoreItems; + self.showLoadMoreHeader = self.conversationSnapshot.canLoadMoreItems; } - (void)setShowLoadMoreHeader:(BOOL)showLoadMoreHeader @@ -4136,6 +4158,7 @@ typedef enum : NSUInteger { if (self.shouldObserveVMUpdates) { OWSLogVerbose(@"resume observation of view model."); + [self updateConversationSnapshot]; [self resetContentAndLayout]; [self updateBackButtonUnreadCount]; [self updateNavigationBarSubtitleLabel]; @@ -4610,6 +4633,7 @@ typedef enum : NSUInteger { return; } + [self updateConversationSnapshot]; [self updateBackButtonUnreadCount]; [self updateNavigationBarSubtitleLabel]; @@ -4901,6 +4925,17 @@ typedef enum : NSUInteger { [self.inputToolbar updateLayoutWithSafeAreaInsets:safeAreaInsets]; } +#pragma mark - Conversation Snapshot + +- (void)updateConversationSnapshot +{ + ConversationSnapshot *conversationSnapshot = [ConversationSnapshot new]; + conversationSnapshot.viewItems = self.conversationViewModel.viewItems; + conversationSnapshot.dynamicInteractions = self.conversationViewModel.dynamicInteractions; + conversationSnapshot.canLoadMoreItems = self.conversationViewModel.canLoadMoreItems; + _conversationSnapshot = conversationSnapshot; +} + @end NS_ASSUME_NONNULL_END From 8b3d08c7e3e166b13013b93d5ebd386571a6ea6d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 19 Feb 2019 17:49:40 -0500 Subject: [PATCH 2/5] Introduce ConversationSnapshot. --- .../ConversationViewController.m | 26 +++++++++---- .../ConversationView/ConversationViewModel.h | 2 +- .../ConversationView/ConversationViewModel.m | 39 ++++++++++++------- SignalMessaging/utils/ThreadUtil.m | 15 +++++++ 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 891f994c2..a5c976bea 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -450,11 +450,11 @@ typedef enum : NSUInteger { NSString *_Nullable recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId]; NSData *_Nullable groupId = notification.userInfo[kNSNotificationKey_ProfileGroupId]; if (recipientId.length > 0 && [self.thread.recipientIdentifiers containsObject:recipientId]) { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } else if (groupId.length > 0 && self.thread.isGroupThread) { TSGroupThread *groupThread = (TSGroupThread *)self.thread; if ([groupThread.groupModel.groupId isEqualToData:groupId]) { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; [self ensureBannerState]; } } @@ -868,6 +868,7 @@ typedef enum : NSUInteger { // Avoid layout corrupt issues and out-of-date message subtitles. self.lastReloadDate = [NSDate new]; [self.conversationViewModel viewDidResetContentAndLayout]; + [self tryToUpdateConversationSnapshot]; [self.collectionView.collectionViewLayout invalidateLayout]; [self.collectionView reloadData]; @@ -2437,7 +2438,7 @@ typedef enum : NSUInteger { - (void)contactsViewHelperDidUpdateContacts { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } - (void)createConversationScrollButtons @@ -2475,7 +2476,7 @@ typedef enum : NSUInteger { _hasUnreadMessages = hasUnreadMessages; self.scrollDownButton.hasUnreadMessages = hasUnreadMessages; - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } - (void)scrollDownButtonTapped @@ -2620,7 +2621,7 @@ typedef enum : NSUInteger { [self showApprovalDialogForAttachment:attachment]; [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } - (void)messageWasSent:(TSOutgoingMessage *)message @@ -2980,7 +2981,7 @@ typedef enum : NSUInteger { [self messageWasSent:message]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } }]; } @@ -3626,7 +3627,7 @@ typedef enum : NSUInteger { [self messageWasSent:message]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } }); } @@ -4029,7 +4030,7 @@ typedef enum : NSUInteger { [self clearDraft]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractions]; + [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } } @@ -4927,6 +4928,15 @@ typedef enum : NSUInteger { #pragma mark - Conversation Snapshot +- (void)tryToUpdateConversationSnapshot +{ + if (!self.isObservingVMUpdates) { + return; + } + + [self updateConversationSnapshot]; +} + - (void)updateConversationSnapshot { ConversationSnapshot *conversationSnapshot = [ConversationSnapshot new]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h index c4d781b3a..902413760 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h @@ -93,7 +93,7 @@ typedef NS_ENUM(NSUInteger, ConversationUpdateItemType) { focusMessageIdOnOpen:(nullable NSString *)focusMessageIdOnOpen delegate:(id)delegate NS_DESIGNATED_INITIALIZER; -- (void)ensureDynamicInteractions; +- (void)ensureDynamicInteractionsAndUpdateIfNecessary:(BOOL)updateIfNecessary; - (void)clearUnreadMessagesIndicator; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index a5e589734..f1086644e 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -273,7 +273,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; { OWSAssertIsOnMainThread(); - [self ensureDynamicInteractions]; + [self ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } - (void)profileWhitelistDidChange:(NSNotification *)notification @@ -308,7 +308,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.typingIndicatorsSender = [self.typingIndicators typingRecipientIdForThread:self.thread]; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractions]; + [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; [self.primaryStorage updateUIDatabaseConnectionToLatest]; [self createNewMessageMapping]; @@ -464,21 +464,32 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; } -- (void)ensureDynamicInteractions +- (void)ensureDynamicInteractionsAndUpdateIfNecessary:(BOOL)updateIfNecessary { OWSAssertIsOnMainThread(); const int currentMaxRangeSize = (int)self.messageMapping.desiredLength; const int maxRangeSize = MAX(kConversationInitialMaxRangeSize, currentMaxRangeSize); - self.dynamicInteractions = [ThreadUtil ensureDynamicInteractionsForThread:self.thread - contactsManager:self.contactsManager - blockingManager:self.blockingManager - dbConnection:self.editingDatabaseConnection - hideUnreadMessagesIndicator:self.hasClearedUnreadMessagesIndicator - lastUnreadIndicator:self.dynamicInteractions.unreadIndicator - focusMessageId:self.focusMessageIdOnOpen - maxRangeSize:maxRangeSize]; + ThreadDynamicInteractions *dynamicInteractions = + [ThreadUtil ensureDynamicInteractionsForThread:self.thread + contactsManager:self.contactsManager + blockingManager:self.blockingManager + dbConnection:self.editingDatabaseConnection + hideUnreadMessagesIndicator:self.hasClearedUnreadMessagesIndicator + lastUnreadIndicator:self.dynamicInteractions.unreadIndicator + focusMessageId:self.focusMessageIdOnOpen + maxRangeSize:maxRangeSize]; + BOOL didChange = ![NSObject isNullableObject:self.dynamicInteractions equalTo:dynamicInteractions]; + self.dynamicInteractions = dynamicInteractions; + + if (didChange && updateIfNecessary) { + if (![self reloadViewItems]) { + OWSFailDebug(@"Failed to reload view items."); + } + + [self.delegate conversationViewModelDidUpdate:ConversationUpdate.reloadUpdate]; + } } - (nullable id)viewItemForUnreadMessagesIndicator @@ -519,7 +530,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; if (self.dynamicInteractions.unreadIndicator) { // If we've just cleared the "unread messages" indicator, // update the dynamic interactions. - [self ensureDynamicInteractions]; + [self ensureDynamicInteractionsAndUpdateIfNecessary:YES]; } } @@ -962,7 +973,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractions]; + [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; if (![self reloadViewItems]) { OWSFailDebug(@"failed to reload view items in resetMapping."); @@ -1584,7 +1595,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractions]; + [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; if (![self reloadViewItems]) { OWSFailDebug(@"failed to reload view items in resetMapping."); diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index 2d5b182f3..f42badd4c 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -45,6 +45,21 @@ NS_ASSUME_NONNULL_BEGIN self.unreadIndicator = nil; } +- (BOOL)isEqual:(id)object +{ + if (self == object) { + return YES; + } + + if (![object isKindOfClass:[ThreadDynamicInteractions class]]) { + return NO; + } + + ThreadDynamicInteractions *other = (ThreadDynamicInteractions *)object; + return ([NSObject isNullableObject:self.focusMessagePosition equalTo:other.focusMessagePosition] && + [NSObject isNullableObject:self.unreadIndicator equalTo:other.unreadIndicator]); +} + @end #pragma mark - From 01cc5cb36a4b22aed9346139721eee0a0008670e Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 20 Feb 2019 10:56:36 -0500 Subject: [PATCH 3/5] "Bump build to 2.37.0.3." --- Signal/Signal-Info.plist | 2 +- SignalShareExtension/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 3a5412e01..5ce47d308 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -47,7 +47,7 @@ CFBundleVersion - 2.37.0.2 + 2.37.0.3 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index d569851bb..d9e2eb8bb 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.37.0 CFBundleVersion - 2.37.0.2 + 2.37.0.3 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From 3f1312da6b38386473647732cdcfdf1a92866bbe Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 20 Feb 2019 11:42:52 -0500 Subject: [PATCH 4/5] Revert "Introduce ConversationSnapshot." This reverts commit 8b3d08c7e3e166b13013b93d5ebd386571a6ea6d. --- .../ConversationViewController.m | 26 ++++--------- .../ConversationView/ConversationViewModel.h | 2 +- .../ConversationView/ConversationViewModel.m | 39 +++++++------------ SignalMessaging/utils/ThreadUtil.m | 15 ------- 4 files changed, 23 insertions(+), 59 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index a5c976bea..891f994c2 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -450,11 +450,11 @@ typedef enum : NSUInteger { NSString *_Nullable recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId]; NSData *_Nullable groupId = notification.userInfo[kNSNotificationKey_ProfileGroupId]; if (recipientId.length > 0 && [self.thread.recipientIdentifiers containsObject:recipientId]) { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } else if (groupId.length > 0 && self.thread.isGroupThread) { TSGroupThread *groupThread = (TSGroupThread *)self.thread; if ([groupThread.groupModel.groupId isEqualToData:groupId]) { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; [self ensureBannerState]; } } @@ -868,7 +868,6 @@ typedef enum : NSUInteger { // Avoid layout corrupt issues and out-of-date message subtitles. self.lastReloadDate = [NSDate new]; [self.conversationViewModel viewDidResetContentAndLayout]; - [self tryToUpdateConversationSnapshot]; [self.collectionView.collectionViewLayout invalidateLayout]; [self.collectionView reloadData]; @@ -2438,7 +2437,7 @@ typedef enum : NSUInteger { - (void)contactsViewHelperDidUpdateContacts { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } - (void)createConversationScrollButtons @@ -2476,7 +2475,7 @@ typedef enum : NSUInteger { _hasUnreadMessages = hasUnreadMessages; self.scrollDownButton.hasUnreadMessages = hasUnreadMessages; - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } - (void)scrollDownButtonTapped @@ -2621,7 +2620,7 @@ typedef enum : NSUInteger { [self showApprovalDialogForAttachment:attachment]; [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } - (void)messageWasSent:(TSOutgoingMessage *)message @@ -2981,7 +2980,7 @@ typedef enum : NSUInteger { [self messageWasSent:message]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } }]; } @@ -3627,7 +3626,7 @@ typedef enum : NSUInteger { [self messageWasSent:message]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } }); } @@ -4030,7 +4029,7 @@ typedef enum : NSUInteger { [self clearDraft]; if (didAddToProfileWhitelist) { - [self.conversationViewModel ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self.conversationViewModel ensureDynamicInteractions]; } } @@ -4928,15 +4927,6 @@ typedef enum : NSUInteger { #pragma mark - Conversation Snapshot -- (void)tryToUpdateConversationSnapshot -{ - if (!self.isObservingVMUpdates) { - return; - } - - [self updateConversationSnapshot]; -} - - (void)updateConversationSnapshot { ConversationSnapshot *conversationSnapshot = [ConversationSnapshot new]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h index 902413760..c4d781b3a 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h @@ -93,7 +93,7 @@ typedef NS_ENUM(NSUInteger, ConversationUpdateItemType) { focusMessageIdOnOpen:(nullable NSString *)focusMessageIdOnOpen delegate:(id)delegate NS_DESIGNATED_INITIALIZER; -- (void)ensureDynamicInteractionsAndUpdateIfNecessary:(BOOL)updateIfNecessary; +- (void)ensureDynamicInteractions; - (void)clearUnreadMessagesIndicator; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index f1086644e..a5e589734 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -273,7 +273,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; { OWSAssertIsOnMainThread(); - [self ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self ensureDynamicInteractions]; } - (void)profileWhitelistDidChange:(NSNotification *)notification @@ -308,7 +308,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.typingIndicatorsSender = [self.typingIndicators typingRecipientIdForThread:self.thread]; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; + [self ensureDynamicInteractions]; [self.primaryStorage updateUIDatabaseConnectionToLatest]; [self createNewMessageMapping]; @@ -464,32 +464,21 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; } -- (void)ensureDynamicInteractionsAndUpdateIfNecessary:(BOOL)updateIfNecessary +- (void)ensureDynamicInteractions { OWSAssertIsOnMainThread(); const int currentMaxRangeSize = (int)self.messageMapping.desiredLength; const int maxRangeSize = MAX(kConversationInitialMaxRangeSize, currentMaxRangeSize); - ThreadDynamicInteractions *dynamicInteractions = - [ThreadUtil ensureDynamicInteractionsForThread:self.thread - contactsManager:self.contactsManager - blockingManager:self.blockingManager - dbConnection:self.editingDatabaseConnection - hideUnreadMessagesIndicator:self.hasClearedUnreadMessagesIndicator - lastUnreadIndicator:self.dynamicInteractions.unreadIndicator - focusMessageId:self.focusMessageIdOnOpen - maxRangeSize:maxRangeSize]; - BOOL didChange = ![NSObject isNullableObject:self.dynamicInteractions equalTo:dynamicInteractions]; - self.dynamicInteractions = dynamicInteractions; - - if (didChange && updateIfNecessary) { - if (![self reloadViewItems]) { - OWSFailDebug(@"Failed to reload view items."); - } - - [self.delegate conversationViewModelDidUpdate:ConversationUpdate.reloadUpdate]; - } + self.dynamicInteractions = [ThreadUtil ensureDynamicInteractionsForThread:self.thread + contactsManager:self.contactsManager + blockingManager:self.blockingManager + dbConnection:self.editingDatabaseConnection + hideUnreadMessagesIndicator:self.hasClearedUnreadMessagesIndicator + lastUnreadIndicator:self.dynamicInteractions.unreadIndicator + focusMessageId:self.focusMessageIdOnOpen + maxRangeSize:maxRangeSize]; } - (nullable id)viewItemForUnreadMessagesIndicator @@ -530,7 +519,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; if (self.dynamicInteractions.unreadIndicator) { // If we've just cleared the "unread messages" indicator, // update the dynamic interactions. - [self ensureDynamicInteractionsAndUpdateIfNecessary:YES]; + [self ensureDynamicInteractions]; } } @@ -973,7 +962,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; + [self ensureDynamicInteractions]; if (![self reloadViewItems]) { OWSFailDebug(@"failed to reload view items in resetMapping."); @@ -1595,7 +1584,7 @@ static const int kYapDatabaseRangeMaxLength = 25000; self.collapseCutoffDate = [NSDate new]; - [self ensureDynamicInteractionsAndUpdateIfNecessary:NO]; + [self ensureDynamicInteractions]; if (![self reloadViewItems]) { OWSFailDebug(@"failed to reload view items in resetMapping."); diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index f42badd4c..2d5b182f3 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -45,21 +45,6 @@ NS_ASSUME_NONNULL_BEGIN self.unreadIndicator = nil; } -- (BOOL)isEqual:(id)object -{ - if (self == object) { - return YES; - } - - if (![object isKindOfClass:[ThreadDynamicInteractions class]]) { - return NO; - } - - ThreadDynamicInteractions *other = (ThreadDynamicInteractions *)object; - return ([NSObject isNullableObject:self.focusMessagePosition equalTo:other.focusMessagePosition] && - [NSObject isNullableObject:self.unreadIndicator equalTo:other.unreadIndicator]); -} - @end #pragma mark - From 67632a48e6e08205936ad3c085bacfbf0946569f Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 20 Feb 2019 11:43:02 -0500 Subject: [PATCH 5/5] Revert "Introduce ConversationSnapshot." This reverts commit 9471f24cf38519a74f46fa7c45acc96c11ac02d2. --- .../ConversationViewController.m | 41 ++----------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 891f994c2..a40183cd2 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -108,25 +108,6 @@ typedef enum : NSUInteger { #pragma mark - -// We use snapshots to ensure that the view has a consistent -// representation of view model state which is not updated -// when the view is not observing view model changes. -@interface ConversationSnapshot : NSObject - -@property (nonatomic) NSArray> *viewItems; -@property (nonatomic) ThreadDynamicInteractions *dynamicInteractions; -@property (nonatomic) BOOL canLoadMoreItems; - -@end - -#pragma mark - - -@implementation ConversationSnapshot - -@end - -#pragma mark - - @interface ConversationViewController () > *)viewItems { - return self.conversationSnapshot.viewItems; + return self.conversationViewModel.viewItems; } - (ThreadDynamicInteractions *)dynamicInteractions { - return self.conversationSnapshot.dynamicInteractions; + return self.conversationViewModel.dynamicInteractions; } - (NSIndexPath *_Nullable)indexPathOfUnreadMessagesIndicator @@ -1718,7 +1696,7 @@ typedef enum : NSUInteger { { OWSAssertDebug(self.conversationViewModel); - self.showLoadMoreHeader = self.conversationSnapshot.canLoadMoreItems; + self.showLoadMoreHeader = self.conversationViewModel.canLoadMoreItems; } - (void)setShowLoadMoreHeader:(BOOL)showLoadMoreHeader @@ -4158,7 +4136,6 @@ typedef enum : NSUInteger { if (self.shouldObserveVMUpdates) { OWSLogVerbose(@"resume observation of view model."); - [self updateConversationSnapshot]; [self resetContentAndLayout]; [self updateBackButtonUnreadCount]; [self updateNavigationBarSubtitleLabel]; @@ -4633,7 +4610,6 @@ typedef enum : NSUInteger { return; } - [self updateConversationSnapshot]; [self updateBackButtonUnreadCount]; [self updateNavigationBarSubtitleLabel]; @@ -4925,17 +4901,6 @@ typedef enum : NSUInteger { [self.inputToolbar updateLayoutWithSafeAreaInsets:safeAreaInsets]; } -#pragma mark - Conversation Snapshot - -- (void)updateConversationSnapshot -{ - ConversationSnapshot *conversationSnapshot = [ConversationSnapshot new]; - conversationSnapshot.viewItems = self.conversationViewModel.viewItems; - conversationSnapshot.dynamicInteractions = self.conversationViewModel.dynamicInteractions; - conversationSnapshot.canLoadMoreItems = self.conversationViewModel.canLoadMoreItems; - _conversationSnapshot = conversationSnapshot; -} - @end NS_ASSUME_NONNULL_END