From 1ed218d5e3db4dcafb71d64251ebaf159bebc612 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 8 Oct 2022 15:17:52 -0400 Subject: [PATCH] Fix new status cells not showing meta indicators or reblog button visibility --- Tusker/API/InstanceFeatures.swift | 2 +- .../Status/StatusCollectionViewCell.swift | 31 ++++++++++++++----- .../TimelineStatusCollectionViewCell.swift | 3 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Tusker/API/InstanceFeatures.swift b/Tusker/API/InstanceFeatures.swift index 99d279a1..df18022b 100644 --- a/Tusker/API/InstanceFeatures.swift +++ b/Tusker/API/InstanceFeatures.swift @@ -30,7 +30,7 @@ struct InstanceFeatures { } var boostToOriginalAudience: Bool { - instanceType == .pleroma + instanceType == .pleroma || instanceType == .mastodon } var profilePinnedStatuses: Bool { diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 4e362e84..bc809f14 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -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 diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 2cce1e7c..9e46d1bb 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -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) {