another.im-ios/Monal/another.im/XMPP/Models/Contact.swift

25 lines
517 B
Swift
Raw Normal View History

2024-11-29 17:35:20 +00:00
import Foundation
import monalxmpp
struct Contact: Identifiable {
let ownerId: Int
let contactJid: String
2024-11-29 22:36:19 +00:00
private let nickname: String?
2024-11-29 17:35:20 +00:00
2024-12-04 15:03:20 +00:00
var id: String { "\(ownerId)|\(contactJid)" }
2024-11-29 17:35:20 +00:00
2024-11-29 22:36:19 +00:00
var name: String {
2024-11-29 23:06:11 +00:00
if let nickname {
nickname.isEmpty ? contactJid : nickname
} else {
contactJid
}
2024-11-29 22:36:19 +00:00
}
2024-11-29 17:35:20 +00:00
init?(_ obj: MLContact) {
ownerId = obj.accountID.intValue
contactJid = obj.contactJid
2024-12-09 17:02:49 +00:00
nickname = obj.contactDisplayName
2024-11-29 17:35:20 +00:00
}
}