Tweak timeline status VO labels to only include attachment text when not blurred

This commit is contained in:
Shadowfacts 2022-12-06 22:29:03 -05:00
parent cde061c77a
commit f96acd33f2
2 changed files with 40 additions and 14 deletions

View File

@ -386,15 +386,28 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
str += AttributedString(contentTextView.attributedText) str += AttributedString(contentTextView.attributedText)
if status.attachments.count > 0 { if status.attachments.count > 0 {
if status.attachments.count == 1 { let includeDescriptions: Bool
let attachment = status.attachments[0] switch Preferences.shared.attachmentBlurMode {
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" case .useStatusSetting:
str += AttributedString(", attachment: \(desc)") includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty
} else { case .always:
for (index, attachment) in status.attachments.enumerated() { 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" 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 { if status.poll != nil {

View File

@ -271,15 +271,28 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
str += AttributedString(contentTextView.attributedText) str += AttributedString(contentTextView.attributedText)
if status.attachments.count > 0 { if status.attachments.count > 0 {
if status.attachments.count == 1 { let includeDescriptions: Bool
let attachment = status.attachments[0] switch Preferences.shared.attachmentBlurMode {
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" case .useStatusSetting:
str += AttributedString(", attachment: \(desc)") includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty
} else { case .always:
for (index, attachment) in status.attachments.enumerated() { 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" 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 { if status.poll != nil {