From d71e2c2eca254c2cc01074dbeebf4233630ebce6 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Sat, 2 Apr 2022 14:12:30 -0700 Subject: [PATCH] Fix group reply cell sizing bug --- .../Group Reply Sheet/StoryGroupReplyCell.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/Stories/Group Reply Sheet/StoryGroupReplyCell.swift b/Signal/src/ViewControllers/HomeView/Stories/Group Reply Sheet/StoryGroupReplyCell.swift index a5f3839469..c6b4c28010 100644 --- a/Signal/src/ViewControllers/HomeView/Stories/Group Reply Sheet/StoryGroupReplyCell.swift +++ b/Signal/src/ViewControllers/HomeView/Stories/Group Reply Sheet/StoryGroupReplyCell.swift @@ -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()!