wip
This commit is contained in:
parent
dce50cddca
commit
ca5e4b930c
|
@ -68,7 +68,21 @@ extension MonalXmppWrapper {
|
|||
|
||||
func chat(with: Chat) -> MonalChatWrapper? {
|
||||
guard let account = accounts.first(where: { $0.id == with.accountId }) else { return nil }
|
||||
guard let contact = contacts.first(where: { $0.ownerId == with.accountId && $0.contactJid == with.participantJid }) else { return nil }
|
||||
|
||||
var contact = contacts.first(where: { $0.ownerId == with.accountId && $0.contactJid == with.participantJid })
|
||||
if contact == nil {
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
Task {
|
||||
await addContact(contactJid: with.participantJid, forAccountID: with.accountId)
|
||||
semaphore.signal()
|
||||
}
|
||||
semaphore.wait()
|
||||
refreshChats()
|
||||
refreshContacts()
|
||||
contact = contacts.first(where: { $0.ownerId == with.accountId && $0.contactJid == with.participantJid })
|
||||
}
|
||||
|
||||
guard let contact else { return nil }
|
||||
let chatModel = MonalChatWrapper(account: account, contact: contact, db: db, xmpp: xmpp)
|
||||
return chatModel
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue