IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/AccountExt.swift
Yusuke Arakawa 6219f4c446
Clarify the difference between screen name and username (#769)
Co-authored-by: Yusuke Arakawa <nekolaboratory@users.noreply.github.com>
2023-02-10 18:30:59 +01:00

26 lines
613 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 displayName.isEmpty || displayName == "" {
return "@\(username)"
}
return displayName
}
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: " ")
}
}