28 lines
617 B
Swift
28 lines
617 B
Swift
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
|
|
}
|
|
}
|