diff --git a/Tusker/Extensions/StatusStateResolver.swift b/Tusker/Extensions/StatusStateResolver.swift index 098abf4156..a51d0bb582 100644 --- a/Tusker/Extensions/StatusStateResolver.swift +++ b/Tusker/Extensions/StatusStateResolver.swift @@ -11,11 +11,10 @@ import Pachyderm extension StatusState { - func resolveFor(status: StatusMO, text: String?) { + func resolveFor(status: StatusMO, height: CGFloat) { let longEnoughToCollapse: Bool if Preferences.shared.collapseLongPosts, - let text = text, - text.count > 500 { + height > 500 { longEnoughToCollapse = true } else { longEnoughToCollapse = false diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index bdfaf09e21..517835d8ab 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -182,7 +182,8 @@ class BaseStatusTableViewCell: UITableViewCell { updateStatusIconsForPreferences(status) if state.unknown { - state.resolveFor(status: status, text: contentTextView.text) + layoutIfNeeded() + state.resolveFor(status: status, height: contentTextView.bounds.height) if state.collapsible! && showStatusAutomatically { state.collapsed = false } diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 2b8fc7f0ed..5fa0c579ee 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -104,7 +104,9 @@ extension StatusCollectionViewCell { favoriteButton.isEnabled = mastodonController.loggedIn if statusState.unknown { - statusState.resolveFor(status: status, text: contentContainer.contentTextView.text) + // layout so that we can take the content height into consideration when deciding whether to collapse + layoutIfNeeded() + statusState.resolveFor(status: status, height: contentContainer.contentTextView.bounds.height) if statusState.collapsible! && showStatusAutomatically { statusState.collapsed = false }