diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 49f61d34..423419a5 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -369,7 +369,13 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti guard let status = mastodonController.persistentContainer.status(for: statusID) else { return nil } - var str = AttributedString("\(status.account.displayOrUserName), ") + var str: AttributedString = "" + if let rebloggerID, + let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { + str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ") + } + str += AttributedString(status.account.displayOrUserName) + str += ", " if statusState.collapsed ?? false { if !status.spoilerText.isEmpty { str += AttributedString(status.spoilerText) @@ -378,15 +384,24 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti str += "collapsed" } else { str += AttributedString(contentTextView.attributedText) - } - if status.attachments.count > 0 { - // TODO: localize me - str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")") - } - if status.poll != nil { - str += ", poll" + 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 desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" + str += AttributedString(", attachment \(index + 1): \(desc)") + } + } + } + if status.poll != nil { + str += ", poll" + } } + str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))") if status.visibility < .unlisted { str += AttributedString(", \(status.visibility.displayName)") @@ -394,10 +409,6 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti if status.localOnly { str += ", local" } - if let rebloggerID, - let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { - str += AttributedString(", reblogged by \(reblogger.displayOrUserName)") - } return NSAttributedString(str) } set {} diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index 6af737ad..538a3f79 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -254,7 +254,13 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { guard let status = mastodonController.persistentContainer.status(for: statusID) else { return nil } - var str = AttributedString("\(status.account.displayOrUserName), ") + var str: AttributedString = "" + if let rebloggerID, + let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { + str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ") + } + str += AttributedString(status.account.displayOrUserName) + str += ", " if statusState.collapsed ?? false { if !status.spoilerText.isEmpty { str += AttributedString(status.spoilerText) @@ -263,15 +269,24 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { str += "collapsed" } else { str += AttributedString(contentTextView.attributedText) - } - if status.attachments.count > 0 { - // TODO: localize me - str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count > 1 ? "s" : "")") - } - if status.poll != nil { - str += ", poll" + 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 desc = attachment.description?.isEmpty == false ? attachment.description! : "no description" + str += AttributedString(", attachment \(index + 1): \(desc)") + } + } + } + if status.poll != nil { + str += ", poll" + } } + str += AttributedString(", \(status.createdAt.formatted(.relative(presentation: .numeric)))") if status.visibility < .unlisted { str += AttributedString(", \(status.visibility.displayName)") @@ -279,10 +294,6 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { if status.localOnly { str += ", local" } - if let rebloggerID, - let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { - str += AttributedString(", reblogged by \(reblogger.displayOrUserName)") - } return NSAttributedString(str) } set {}