IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/AccountExt.swift

27 lines
586 B
Swift
Raw Normal View History

2022-12-25 12:11:51 +00:00
import Foundation
import Models
2023-01-17 10:36:01 +00:00
import NukeUI
import SwiftUI
2022-12-25 12:11:51 +00:00
2023-01-17 10:36:01 +00:00
public extension Account {
2022-12-27 08:11:12 +00:00
private struct Part: Identifiable {
let id = UUID().uuidString
let value: Substring
}
2023-01-17 10:36:01 +00:00
var safeDisplayName: String {
2023-01-03 07:17:47 +00:00
if displayName.isEmpty {
return username
}
return displayName
}
2023-01-17 10:36:01 +00:00
var displayNameWithoutEmojis: String {
var name = safeDisplayName
for emoji in emojis {
name = name.replacingOccurrences(of: ":\(emoji.shortcode):", with: "")
2022-12-27 09:04:39 +00:00
}
return name.split(separator: " ", omittingEmptySubsequences: true).joined(separator: " ")
2022-12-27 09:04:39 +00:00
}
2022-12-25 12:11:51 +00:00
}