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

28 lines
617 B
Swift
Raw Normal View History

2024-11-29 17:35:20 +00:00
import Foundation
import monalxmpp
struct Chat: Identifiable {
let accountId: Int
let participantJid: String
let participantName: String?
var id: String {
"\(accountId)_\(participantJid)"
}
var name: String {
if let participantName, !participantName.isEmpty {
return participantName
} else {
return participantJid
}
}
init?(_ obj: MLContact) {
guard let accId = obj.accountID as? Int else { return nil }
accountId = accId
participantJid = obj.contactJid
participantName = obj.nickName
}
}