forked from zelo72/mastodon-ios
feat: store view state to prevent redundant image rending
This commit is contained in:
parent
2988e71611
commit
10594d1eb6
|
@ -96,6 +96,7 @@ extension StatusSection {
|
|||
|
||||
// set content warning
|
||||
let isStatusTextSensitive = statusContentWarningAttribute?.isStatusTextSensitive ?? (toot.reblog ?? toot).sensitive
|
||||
cell.statusView.isStatusTextSensitive = isStatusTextSensitive
|
||||
cell.statusView.updateContentWarningDisplay(isHidden: !isStatusTextSensitive)
|
||||
cell.statusView.contentWarningTitle.text = (toot.reblog ?? toot).spoilerText.flatMap { spoilerText in
|
||||
guard !spoilerText.isEmpty else { return nil }
|
||||
|
|
|
@ -200,14 +200,7 @@ extension HomeTimelineViewController: UITableViewDelegate {
|
|||
|
||||
return ceil(frame.height)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
||||
if let cell = cell as? StatusTableViewCell {
|
||||
DispatchQueue.main.async {
|
||||
cell.statusView.drawContentWarningImageView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - ContentOffsetAdjustableTimelineViewControllerDelegate
|
||||
|
@ -227,7 +220,7 @@ extension HomeTimelineViewController: TimelineMiddleLoaderTableViewCellDelegate
|
|||
viewModel.loadMiddleSateMachineList
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] ids in
|
||||
guard let self = self else { return }
|
||||
guard let _ = self else { return }
|
||||
if let stateMachine = ids[upperTimelineIndexObjectID] {
|
||||
guard let state = stateMachine.currentState else {
|
||||
assertionFailure()
|
||||
|
|
|
@ -22,6 +22,7 @@ final class StatusView: UIView {
|
|||
static let contentWarningBlurRadius: CGFloat = 12
|
||||
|
||||
weak var delegate: StatusViewDelegate?
|
||||
var isStatusTextSensitive = false
|
||||
|
||||
let headerContainerStackView = UIStackView()
|
||||
|
||||
|
@ -281,7 +282,9 @@ extension StatusView {
|
|||
}
|
||||
|
||||
func drawContentWarningImageView() {
|
||||
guard activeTextLabel.frame != .zero, let text = activeTextLabel.text, !text.isEmpty else {
|
||||
guard activeTextLabel.frame != .zero,
|
||||
isStatusTextSensitive,
|
||||
let text = activeTextLabel.text, !text.isEmpty else {
|
||||
cleanUpContentWarning()
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue