IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/AccountExt.swift
2023-03-02 20:15:07 +01:00

26 lines
610 B
Swift

import Foundation
import Models
import NukeUI
import SwiftUI
public extension Account {
private struct Part: Identifiable {
let id = UUID().uuidString
let value: Substring
}
var safeDisplayName: String {
if let displayName, !displayName.isEmpty {
return displayName
}
return "@\(username)"
}
var displayNameWithoutEmojis: String {
var name = safeDisplayName
for emoji in emojis {
name = name.replacingOccurrences(of: ":\(emoji.shortcode):", with: "")
}
return name.split(separator: " ", omittingEmptySubsequences: true).joined(separator: " ")
}
}