Compare commits
No commits in common. "f96acd33f227d4810bd0bdebc25d9a0c649fc8aa" and "a79b3cfd706c4065bb545dd134b2245e9e22c808" have entirely different histories.
f96acd33f2
...
a79b3cfd70
|
@ -20,30 +20,18 @@ extension AccountMO {
|
||||||
}
|
}
|
||||||
|
|
||||||
var displayNameWithoutCustomEmoji: String {
|
var displayNameWithoutCustomEmoji: String {
|
||||||
let stripped = stripCustomEmoji(from: displayName)
|
if displayName.isEmpty {
|
||||||
if stripped.isEmpty {
|
|
||||||
return username
|
return username
|
||||||
} else {
|
} else {
|
||||||
return stripped
|
return stripCustomEmoji(from: displayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private static let customEmojiRegex = try! NSRegularExpression(pattern: ":[a-zA-Z0-9_]+:", options: [])
|
||||||
|
|
||||||
extension Account {
|
private func stripCustomEmoji(from string: String) -> String {
|
||||||
var displayNameWithoutCustomEmoji: String {
|
let range = NSRange(location: 0, length: string.utf16.count)
|
||||||
let stripped = stripCustomEmoji(from: displayName)
|
return AccountMO.customEmojiRegex.stringByReplacingMatches(in: string, options: [], range: range, withTemplate: "")
|
||||||
if stripped.isEmpty {
|
}
|
||||||
return username
|
|
||||||
} else {
|
|
||||||
return stripped
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private let customEmojiRegex = try! NSRegularExpression(pattern: ":[a-zA-Z0-9_]+:", options: [])
|
|
||||||
|
|
||||||
private func stripCustomEmoji(from string: String) -> String {
|
|
||||||
let range = NSRange(location: 0, length: string.utf16.count)
|
|
||||||
return customEmojiRegex.stringByReplacingMatches(in: string, options: [], range: range, withTemplate: "")
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ class FeaturedProfileCollectionViewCell: UICollectionViewCell {
|
||||||
guard let account else {
|
guard let account else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let s = NSMutableAttributedString(string: "\(account.displayNameWithoutCustomEmoji), ")
|
let s = NSMutableAttributedString(string: "\(account.displayName), ")
|
||||||
s.append(noteTextView.attributedText)
|
s.append(noteTextView.attributedText)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ class AccountCollectionViewCell: UICollectionViewListCell {
|
||||||
let account = mastodonController.persistentContainer.account(for: accountID) else {
|
let account = mastodonController.persistentContainer.account(for: accountID) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var str = AttributedString(account.displayNameWithoutCustomEmoji)
|
var str = AttributedString(account.displayOrUserName)
|
||||||
str += ", @"
|
str += ", @"
|
||||||
str += AttributedString(account.acct)
|
str += AttributedString(account.acct)
|
||||||
return NSAttributedString(str)
|
return NSAttributedString(str)
|
||||||
|
|
|
@ -372,9 +372,9 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
var str: AttributedString = ""
|
var str: AttributedString = ""
|
||||||
if let rebloggerID,
|
if let rebloggerID,
|
||||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||||
str += AttributedString("Reblogged by \(reblogger.displayNameWithoutCustomEmoji): ")
|
str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ")
|
||||||
}
|
}
|
||||||
str += AttributedString(status.account.displayNameWithoutCustomEmoji)
|
str += AttributedString(status.account.displayOrUserName)
|
||||||
str += ", "
|
str += ", "
|
||||||
if statusState.collapsed ?? false {
|
if statusState.collapsed ?? false {
|
||||||
if !status.spoilerText.isEmpty {
|
if !status.spoilerText.isEmpty {
|
||||||
|
@ -386,28 +386,15 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
str += AttributedString(contentTextView.attributedText)
|
str += AttributedString(contentTextView.attributedText)
|
||||||
|
|
||||||
if status.attachments.count > 0 {
|
if status.attachments.count > 0 {
|
||||||
let includeDescriptions: Bool
|
if status.attachments.count == 1 {
|
||||||
switch Preferences.shared.attachmentBlurMode {
|
let attachment = status.attachments[0]
|
||||||
case .useStatusSetting:
|
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||||
includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty
|
str += AttributedString(", attachment: \(desc)")
|
||||||
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: \(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 {
|
} else {
|
||||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count == 1 ? "" : "s")")
|
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 {
|
if status.poll != nil {
|
||||||
|
|
|
@ -257,9 +257,9 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
var str: AttributedString = ""
|
var str: AttributedString = ""
|
||||||
if let rebloggerID,
|
if let rebloggerID,
|
||||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||||
str += AttributedString("Reblogged by \(reblogger.displayNameWithoutCustomEmoji): ")
|
str += AttributedString("Reblogged by \(reblogger.displayOrUserName): ")
|
||||||
}
|
}
|
||||||
str += AttributedString(status.account.displayNameWithoutCustomEmoji)
|
str += AttributedString(status.account.displayOrUserName)
|
||||||
str += ", "
|
str += ", "
|
||||||
if statusState.collapsed ?? false {
|
if statusState.collapsed ?? false {
|
||||||
if !status.spoilerText.isEmpty {
|
if !status.spoilerText.isEmpty {
|
||||||
|
@ -271,28 +271,15 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
str += AttributedString(contentTextView.attributedText)
|
str += AttributedString(contentTextView.attributedText)
|
||||||
|
|
||||||
if status.attachments.count > 0 {
|
if status.attachments.count > 0 {
|
||||||
let includeDescriptions: Bool
|
if status.attachments.count == 1 {
|
||||||
switch Preferences.shared.attachmentBlurMode {
|
let attachment = status.attachments[0]
|
||||||
case .useStatusSetting:
|
let desc = attachment.description?.isEmpty == false ? attachment.description! : "no description"
|
||||||
includeDescriptions = !Preferences.shared.blurMediaBehindContentWarning || status.spoilerText.isEmpty
|
str += AttributedString(", attachment: \(desc)")
|
||||||
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: \(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 {
|
} else {
|
||||||
str += AttributedString(", \(status.attachments.count) attachment\(status.attachments.count == 1 ? "" : "s")")
|
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 {
|
if status.poll != nil {
|
||||||
|
|
Loading…
Reference in New Issue