forked from shadowfacts/Tusker
Consider content height, not just char count, when collapsing posts
Closes #205
This commit is contained in:
parent
20986ba3f0
commit
7fe06d42ce
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue