From cbb62218b046e85753f21dbc72b6a6b53155083f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Wo=CC=81jcik?= Date: Thu, 25 Nov 2021 12:26:25 +0100 Subject: [PATCH] Fixed possible deadlock #siskinim-317 --- SiskinIM/util/ContactManager.swift | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/SiskinIM/util/ContactManager.swift b/SiskinIM/util/ContactManager.swift index 1bcbeb08..05a31c03 100644 --- a/SiskinIM/util/ContactManager.swift +++ b/SiskinIM/util/ContactManager.swift @@ -120,23 +120,25 @@ public class ContactManager { } public func update(name: String?, for key: Contact.Key) { - guard let contact = existingContact(for: key) else { - return; - } - - DispatchQueue.main.async { - contact.displayName = name ?? key.jid.stringValue; + dispatcher.async { + guard let contact = self.items[key]?.contact else { + return; + } + DispatchQueue.main.async { + contact.displayName = name ?? key.jid.stringValue; + } } } public func update(presence: Presence?, for key: Contact.Key) { - guard let contact = existingContact(for: key) else { - return; - } - - DispatchQueue.main.async { - contact.status = presence?.show; - contact.description = presence?.status; + dispatcher.async { + guard let contact = self.items[key]?.contact else { + return; + } + DispatchQueue.main.async { + contact.status = presence?.show; + contact.description = presence?.status; + } } }