From 527706154a155df3f8bef6babe421c41c461ada5 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 26 Nov 2022 17:28:55 -0500 Subject: [PATCH] Fix long status table view cells not getting collapsed --- Tusker/Extensions/StatusStateResolver.swift | 4 ++-- Tusker/Views/Status/BaseStatusTableViewCell.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tusker/Extensions/StatusStateResolver.swift b/Tusker/Extensions/StatusStateResolver.swift index a51d0bb5..34f8bd8a 100644 --- a/Tusker/Extensions/StatusStateResolver.swift +++ b/Tusker/Extensions/StatusStateResolver.swift @@ -11,10 +11,10 @@ import Pachyderm extension StatusState { - func resolveFor(status: StatusMO, height: CGFloat) { + func resolveFor(status: StatusMO, height: CGFloat, textLength: Int? = nil) { let longEnoughToCollapse: Bool if Preferences.shared.collapseLongPosts, - height > 500 { + height > 500 || (textLength != nil && textLength! > 500) { longEnoughToCollapse = true } else { longEnoughToCollapse = false diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index a314ce89..c85c82b9 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -182,8 +182,8 @@ class BaseStatusTableViewCell: UITableViewCell { updateStatusIconsForPreferences(status) if state.unknown { - layoutIfNeeded() - state.resolveFor(status: status, height: contentTextView.bounds.height) + // for some reason the height here can't be computed correctly, so we fallback to the old hack of just considering raw length + state.resolveFor(status: status, height: 0, textLength: contentTextView.attributedText.length) if state.collapsible! && showStatusAutomatically { state.collapsed = false }