Fix new status cells not showing meta indicators or reblog button visibility

This commit is contained in:
Shadowfacts 2022-10-08 15:17:52 -04:00
parent 0fee770411
commit 1ed218d5e3
3 changed files with 26 additions and 10 deletions

View File

@ -30,7 +30,7 @@ struct InstanceFeatures {
}
var boostToOriginalAudience: Bool {
instanceType == .pleroma
instanceType == .pleroma || instanceType == .mastodon
}
var profilePinnedStatuses: Bool {

View File

@ -99,14 +99,7 @@ extension StatusCollectionViewCell {
contentWarningLabel.setEmojis(status.emojis, identifier: statusID)
}
let reblogDisabled: Bool
if mastodonController.instanceFeatures.boostToOriginalAudience {
reblogDisabled = status.visibility == .direct || (status.visibility == .private && mastodonController.loggedIn && accountID != mastodonController.account.id)
} else {
reblogDisabled = status.visibility == .direct || status.visibility == .private
}
reblogButton.isEnabled = !reblogDisabled && mastodonController.loggedIn
reblogButton.isEnabled = reblogEnabled(status: status)
replyButton.isEnabled = mastodonController.loggedIn
favoriteButton.isEnabled = mastodonController.loggedIn
@ -130,6 +123,20 @@ extension StatusCollectionViewCell {
}
}
private func reblogEnabled(status: StatusMO) -> Bool {
guard mastodonController.loggedIn else {
return false
}
if status.visibility == .direct || status.visibility == .private {
if mastodonController.instanceFeatures.boostToOriginalAudience,
status.account.id == mastodonController.account.id {
return true
}
return false
}
return true
}
func updateAccountUI(account: AccountMO) {
avatarImageView.update(for: account.avatar)
displayNameLabel.updateForAccountDisplayName(account: account)
@ -139,6 +146,14 @@ extension StatusCollectionViewCell {
func baseUpdateUIForPreferences(status: StatusMO) {
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * Self.avatarImageViewSize
contentContainer.attachmentsView.contentHidden = Preferences.shared.blurAllMedia || status.sensitive
let reblogButtonImage: UIImage
if Preferences.shared.alwaysShowStatusVisibilityIcon || reblogEnabled(status: status) {
reblogButtonImage = UIImage(systemName: "repeat")!
} else {
reblogButtonImage = UIImage(systemName: status.visibility.imageName)!
}
reblogButton.setImage(reblogButtonImage, for: .normal)
}
// only called when isGrayscale does not match the pref

View File

@ -223,7 +223,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
}
var showReplyIndicator: Bool {
// TODO: needed once conversation controller refactored
false
true
}
var showPinned: Bool {
// TODO: needed once profile controller refactored
@ -393,6 +393,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
} else {
metaIndicatorsView.allowedIndicators = .all.subtracting(.reply)
}
metaIndicatorsView.updateUI(status: status)
if let rebloggerID,
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {