From 880408b04aa46a72eb17289f2bc4c955b3f62be0 Mon Sep 17 00:00:00 2001 From: Woit Date: Fri, 29 Nov 2024 23:36:19 +0100 Subject: [PATCH] wip --- Monal/another.im/Views/Main/Contacts/ContactsScreen.swift | 2 +- Monal/another.im/XMPP/Models/Chat.swift | 8 ++++---- Monal/another.im/XMPP/Models/Contact.swift | 8 ++++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Monal/another.im/Views/Main/Contacts/ContactsScreen.swift b/Monal/another.im/Views/Main/Contacts/ContactsScreen.swift index 564b01e..031d8e4 100644 --- a/Monal/another.im/Views/Main/Contacts/ContactsScreen.swift +++ b/Monal/another.im/Views/Main/Contacts/ContactsScreen.swift @@ -50,7 +50,7 @@ private struct ContactsScreenRow: View { var body: some View { SharedListRow( - iconType: .charCircle(contact.name ?? contact.contactJid), + iconType: .charCircle(contact.name), text: contact.contactJid, controlType: .none ) diff --git a/Monal/another.im/XMPP/Models/Chat.swift b/Monal/another.im/XMPP/Models/Chat.swift index d452e16..5ae8a92 100644 --- a/Monal/another.im/XMPP/Models/Chat.swift +++ b/Monal/another.im/XMPP/Models/Chat.swift @@ -19,9 +19,9 @@ struct Chat: Identifiable { } init?(_ obj: MLContact) { - guard let accId = obj.accountID as? Int else { return nil } - accountId = accId - participantJid = obj.contactJid - participantName = obj.nickName + guard let contact = Contact(obj) else { return nil } + accountId = contact.ownerId + participantJid = contact.contactJid + participantName = contact.name } } diff --git a/Monal/another.im/XMPP/Models/Contact.swift b/Monal/another.im/XMPP/Models/Contact.swift index 0227c68..37fdf17 100644 --- a/Monal/another.im/XMPP/Models/Contact.swift +++ b/Monal/another.im/XMPP/Models/Contact.swift @@ -4,13 +4,17 @@ import monalxmpp struct Contact: Identifiable { let ownerId: Int let contactJid: String - let name: String? + private let nickname: String? var id: String { contactJid } + var name: String { + nickname ?? contactJid + } + init?(_ obj: MLContact) { ownerId = obj.accountID.intValue contactJid = obj.contactJid - name = obj.nickName.isEmpty ? nil : obj.nickName + nickname = obj.nickName } }