Tusker/Tusker/Views/AccountDisplayNameLabel.swift

33 lines
965 B
Swift

//
// AccountDisplayNameLabel.swift
// Tusker
//
// Created by Shadowfacts on 5/14/23.
// Copyright © 2023 Shadowfacts. All rights reserved.
//
import UIKit
import Pachyderm
class AccountDisplayNameLabel: EmojiLabel {
private var accountID: String?
// store the display name, so that if it changes the label updates w/o changing the id
private var accountDisplayName: String?
func updateForAccountDisplayName(account: some AccountProtocol) {
guard accountID != account.id || accountDisplayName != account.displayName || Preferences.shared.hideCustomEmojiInUsernames != hasEmojis else {
return
}
accountID = account.id
accountDisplayName = account.displayName
self.text = accountDisplayName
if Preferences.shared.hideCustomEmojiInUsernames {
self.removeEmojis()
} else {
self.setEmojis(account.emojis, identifier: account.id)
}
}
}