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

28 lines
624 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) {
2024-11-29 22:36:19 +00:00
guard let contact = Contact(obj) else { return nil }
accountId = contact.ownerId
participantJid = contact.contactJid
participantName = contact.name
2024-11-29 17:35:20 +00:00
}
}