Respond to CR.

This commit is contained in:
Matthew Chen 2018-09-25 16:05:53 -04:00
parent 8910f1f65a
commit 7b2dd19fb8
4 changed files with 14 additions and 4 deletions

View File

@ -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;

View File

@ -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 <ConversationViewLayoutItem, OWSAudioPlayerDelegate>
@property (nonatomic, readonly) TSInteraction *interaction;
@property (nonatomic, nullable, readonly) TSThread *incomingMessageAuthorThread;
@property (nonatomic, readonly, nullable) OWSQuotedReplyModel *quotedReply;
@property (nonatomic, readonly) BOOL isGroupThread;

View File

@ -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;

View File

@ -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);