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-11-29 22:36:19 +00:00
|
|
|
nickname = obj.nickName
|
2024-11-29 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|