Skip to content

Commit

Permalink
Control the height of the compose window a little better.
Browse files Browse the repository at this point in the history
Avoids the known hang, which was caused by getting stuck in a loop setting the frame back and forth over and over. Looked like it was adding and then removing (and then adding, etc) the height of a single line of text. Possible the username was shifting back and forth between truncating and wrapping, but have not confirmed that.

Fixes #705 IOS client consistently hangs when writing new post at ~= 150 chars
  • Loading branch information
whattherestimefor committed Dec 18, 2024
1 parent 7961514 commit 804a5d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ extension ComposeContentViewModel {
guard let self = self else { return }
guard self.composeContentTableViewCellIsInTableView(tableView) else { return }
UIView.performWithoutAnimation {
tableView.beginUpdates()
self.composeContentTableViewCell.frame.size.height = height
tableView.endUpdates()
if height != self.composeContentTableViewCell.contentHeight {
tableView.beginUpdates()
self.composeContentTableViewCell.contentHeight = height
self.composeContentTableViewCell.invalidateIntrinsicContentSize()
tableView.endUpdates()
}
}
}
.store(in: &disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import UIKit
import UIHostingConfigurationBackport

final class ComposeContentTableViewCell: UITableViewCell {

var contentHeight: CGFloat?

override var intrinsicContentSize: CGSize {
let superContentSize = super.intrinsicContentSize
return CGSize(width: superContentSize.width, height: contentHeight ?? superContentSize.height)
}

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
Expand Down

0 comments on commit 804a5d0

Please sign in to comment.