diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 219abf3d4..1407db90d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -268,8 +268,8 @@ NS_ASSUME_NONNULL_BEGIN return NO; } - TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.viewItem.interaction; - TSThread *authorThread = [TSContactThread getOrCreateThreadWithContactId:incomingMessage.authorId]; + OWSAssertDebug(self.viewItem.incomingMessageAuthorThread); + TSThread *authorThread = self.viewItem.incomingMessageAuthorThread; UIImage *_Nullable authorAvatarImage = [OWSAvatarBuilder buildImageForThread:authorThread diameter:self.avatarSize contactsManager:contactsManager]; self.avatarView.image = authorAvatarImage; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h index 794d250b6..efa514bb2 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h @@ -33,6 +33,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType); @class TSAttachmentPointer; @class TSAttachmentStream; @class TSInteraction; +@class TSThread; @class YapDatabaseReadTransaction; // This is a ViewModel for cells in the conversation view. @@ -45,6 +46,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType); @interface ConversationViewItem : NSObject @property (nonatomic, readonly) TSInteraction *interaction; +@property (nonatomic, nullable, readonly) TSThread *incomingMessageAuthorThread; + @property (nonatomic, readonly, nullable) OWSQuotedReplyModel *quotedReply; @property (nonatomic, readonly) BOOL isGroupThread; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index 3903de6bb..ffa56f9d2 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -63,12 +63,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) @property (nonatomic, nullable) DisplayableText *displayableBodyText; @property (nonatomic, nullable) DisplayableText *displayableQuotedText; @property (nonatomic, nullable) OWSQuotedReplyModel *quotedReply; -@property (nonatomic, readonly, nullable) NSString *quotedAttachmentMimetype; -@property (nonatomic, readonly, nullable) NSString *quotedRecipientId; @property (nonatomic, nullable) TSAttachmentStream *attachmentStream; @property (nonatomic, nullable) TSAttachmentPointer *attachmentPointer; @property (nonatomic, nullable) ContactShareViewModel *contactShare; @property (nonatomic) CGSize mediaSize; +@property (nonatomic, nullable) TSThread *incomingMessageAuthorThread; @end @@ -94,6 +93,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) _interaction = interaction; _isGroupThread = isGroupThread; _conversationStyle = conversationStyle; + _incomingMessageAuthorThread = ([interaction isKindOfClass:[TSIncomingMessage class]] + ? [TSContactThread getOrCreateThreadWithContactId:((TSIncomingMessage *)interaction).authorId] + : nil); [self ensureViewState:transaction]; @@ -105,6 +107,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSAssertDebug(interaction); _interaction = interaction; + _incomingMessageAuthorThread = ([interaction isKindOfClass:[TSIncomingMessage class]] + ? [TSContactThread getOrCreateThreadWithContactId:((TSIncomingMessage *)interaction).authorId] + : nil); self.hasViewState = NO; self.messageCellType = OWSMessageCellType_Unknown; diff --git a/SignalMessaging/utils/OWSAvatarBuilder.m b/SignalMessaging/utils/OWSAvatarBuilder.m index c826eed61..3d66671b4 100644 --- a/SignalMessaging/utils/OWSAvatarBuilder.m +++ b/SignalMessaging/utils/OWSAvatarBuilder.m @@ -221,6 +221,8 @@ typedef void (^OWSAvatarDrawBlock)(CGContextRef context); context:nil] .size; } + } else { + OWSFailDebug(@"Text has invalid bounds."); } CGPoint drawPoint = CGPointMake((diameter - textSize.width) * 0.5f, (diameter - textSize.height) * 0.5f);