diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index c6f4d56ef..32e8d56ca 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3894,7 +3894,7 @@ typedef enum : NSUInteger { transaction:transaction]; }]; } - [self.conversationViewModel appendUnsavedOutgoingMessage:message]; + [self.conversationViewModel appendUnsavedOutgoingTextMessage:message]; [self messageWasSent:message]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h index 834568765..bdbf8f530 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.h @@ -102,7 +102,7 @@ typedef NS_ENUM(NSUInteger, ConversationUpdateItemType) { - (BOOL)canLoadMoreItems; - (nullable NSIndexPath *)ensureLoadWindowContainsQuotedReply:(OWSQuotedReplyModel *)quotedReply; -- (void)appendUnsavedOutgoingMessage:(TSOutgoingMessage *)outgoingMessage; +- (void)appendUnsavedOutgoingTextMessage:(TSOutgoingMessage *)outgoingMessage; @end diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index 0d476112c..c84f226f8 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -1253,13 +1253,20 @@ static const int kYapDatabaseRangeMinLength = 0; tryToAddViewItem(interaction, transaction); }]; } - // Flag to ensure that we only increment once per launch. if (hasError) { OWSLogWarn(@"incrementing version of: %@", TSMessageDatabaseViewExtensionName); [OWSPrimaryStorage incrementVersionOfDatabaseExtension:TSMessageDatabaseViewExtensionName]; } + self.viewItemCache = viewItemCache; + self.viewItems = [self prepareViewItemsForDisplay:viewItems]; + + return !hasError; +} + +- (NSArray> *)prepareViewItemsForDisplay:(NSArray> *)viewItems +{ // Update the "break" properties (shouldShowDate and unreadIndicator) of the view items. BOOL shouldShowDateOnNextViewItem = YES; uint64_t previousViewItemTimestamp = 0; @@ -1488,16 +1495,11 @@ static const int kYapDatabaseRangeMinLength = 0; viewItem.senderName = senderName; } - self.viewItems = viewItems; - self.viewItemCache = viewItemCache; - - return !hasError; + return viewItems; } -- (void)appendUnsavedOutgoingMessage:(TSOutgoingMessage *)outgoingMessage +- (void)appendUnsavedOutgoingTextMessage:(TSOutgoingMessage *)outgoingMessage { -// id viewItem = [[OutgoingUnsavedConversationViewItem alloc] initWithOutgoingMessage:outgoingMessage]; - __block ConversationInteractionViewItem *viewItem; [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) { viewItem = @@ -1514,7 +1516,7 @@ static const int kYapDatabaseRangeMinLength = 0; NSMutableArray> *viewItems = [self.viewItems mutableCopy]; [viewItems addObject:viewItem]; - self.viewItems = viewItems; + self.viewItems = [self prepareViewItemsForDisplay:viewItems]; ConversationUpdate *conversationUpdate = [[ConversationUpdate alloc] initWithConversationUpdateType:ConversationUpdateType_Diff updateItems:@[updateItem] shouldAnimateUpdates:NO];