|
|
|
@ -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<id<ConversationViewItem>> *viewItems;
|
|
|
|
|
@property (nonatomic) ThreadDynamicInteractions *dynamicInteractions;
|
|
|
|
|
@property (nonatomic) BOOL canLoadMoreItems;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
@implementation ConversationSnapshot
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
@interface ConversationViewController () <AttachmentApprovalViewControllerDelegate,
|
|
|
|
|
ContactShareApprovalViewControllerDelegate,
|
|
|
|
|
AVAudioPlayerDelegate,
|
|
|
|
@ -159,7 +140,6 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) TSThread *thread;
|
|
|
|
|
@property (nonatomic, readonly) ConversationViewModel *conversationViewModel;
|
|
|
|
|
@property (nonatomic, readonly) ConversationSnapshot *conversationSnapshot;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) OWSAudioActivity *recordVoiceNoteAudioActivity;
|
|
|
|
|
@property (nonatomic, readonly) NSTimeInterval viewControllerCreatedAt;
|
|
|
|
@ -505,8 +485,6 @@ typedef enum : NSUInteger {
|
|
|
|
|
_conversationViewModel =
|
|
|
|
|
[[ConversationViewModel alloc] initWithThread:thread focusMessageIdOnOpen:focusMessageId delegate:self];
|
|
|
|
|
|
|
|
|
|
[self updateConversationSnapshot];
|
|
|
|
|
|
|
|
|
|
[self updateShouldObserveVMUpdates];
|
|
|
|
|
|
|
|
|
|
self.reloadTimer = [NSTimer weakScheduledTimerWithTimeInterval:1.f
|
|
|
|
@ -774,12 +752,12 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
- (NSArray<id<ConversationViewItem>> *)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
|
|
|
|
|