From f96acd33f227d4810bd0bdebc25d9a0c649fc8aa Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 6 Dec 2022 22:29:03 -0500 Subject: [PATCH] Tweak timeline status VO labels to only include attachment text when not blurred --- .../TimelineStatusCollectionViewCell.swift | 27 ++++++++++++++----- .../Status/TimelineStatusTableViewCell.swift | 27 ++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 5a7fb16666..59cd320748 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -386,15 +386,28 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti str += AttributedString(contentTextView.attributedText) if status.attachments.count > 0 { - if status.attachments.count == 1 { - let attachment = status.attachments[0] - let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" - str += AttributedString(", attachment: \(desc)") - } else { - for (index, attachment) in status.attachments.enumerated() { + let includeDescriptions: Bool + switch Preferences.shared.attachmentBlurMode { + case .useStatusSetting: + includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty + case .always: + includeDescriptions = true + case .never: + includeDescriptions = false + } + if includeDescriptions { + if status.attachments.count == 1 { + let attachment = status.attachments[0] let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" - str += AttributedString(", attachment \(index + 1): \(desc)") + str += AttributedString(", attachment: \(desc)") + } else { + for (index, attachment) in status.attachments.enumerated() { + let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" + str += AttributedString(", attachment \(index + 1): \(desc)") + } } + } else { + str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count == 1 ? "" : "s")") } } if status.poll != nil { diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index ce3bfb6318..3e58beef2f 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -271,15 +271,28 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { str += AttributedString(contentTextView.attributedText) if status.attachments.count > 0 { - if status.attachments.count == 1 { - let attachment = status.attachments[0] - let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" - str += AttributedString(", attachment: \(desc)") - } else { - for (index, attachment) in status.attachments.enumerated() { + let includeDescriptions: Bool + switch Preferences.shared.attachmentBlurMode { + case .useStatusSetting: + includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty + case .always: + includeDescriptions = true + case .never: + includeDescriptions = false + } + if includeDescriptions { + if status.attachments.count == 1 { + let attachment = status.attachments[0] let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" - str += AttributedString(", attachment \(index + 1): \(desc)") + str += AttributedString(", attachment: \(desc)") + } else { + for (index, attachment) in status.attachments.enumerated() { + let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" + str += AttributedString(", attachment \(index + 1): \(desc)") + } } + } else { + str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count == 1 ? "" : "s")") } } if status.poll != nil {