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 contact = Contact(obj) else { return nil } accountId = contact.ownerId participantJid = contact.contactJid participantName = contact.name } }