Fix group reply cell sizing bug

This commit is contained in:
Nora Trapp 2022-04-02 14:12:30 -07:00
parent 4bb1bedbf3
commit d71e2c2eca

View File

@ -256,9 +256,9 @@ class StoryGroupReplyCell: UITableViewCell {
messageMeasurement.rect.width,
messageMeasurement.lastLineRect.width + timestampSpacer + timestampMeasurement.rect.width
]
if cellType.hasAuthor {
contentView.layoutIfNeeded()
possibleMessageBubbleWidths.append(authorNameLabel.width)
if cellType.hasAuthor, let authorDisplayName = item.authorDisplayName {
let authorMeasurement = measure(authorDisplayName.styled(with: .font(authorNameLabel.font)), maxWidth: maxMessageWidth)
possibleMessageBubbleWidths.append(authorMeasurement.rect.width)
}
let finalMessageLabelWidth = possibleMessageBubbleWidths.max()!
@ -276,9 +276,9 @@ class StoryGroupReplyCell: UITableViewCell {
messageMeasurement.rect.width,
timestampMeasurement.rect.width
]
if cellType.hasAuthor {
contentView.layoutIfNeeded()
possibleMessageBubbleWidths.append(authorNameLabel.width)
if cellType.hasAuthor, let authorDisplayName = item.authorDisplayName {
let authorMeasurement = measure(authorDisplayName.styled(with: .font(authorNameLabel.font)), maxWidth: maxMessageWidth)
possibleMessageBubbleWidths.append(authorMeasurement.rect.width)
}
let finalMessageLabelWidth = possibleMessageBubbleWidths.max()!