Skip to content

Commit

Permalink
Fixed possible deadlock #siskinim-317
Browse files Browse the repository at this point in the history
  • Loading branch information
hantu85 committed Nov 25, 2021
1 parent 9a9b523 commit cbb6221
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions SiskinIM/util/ContactManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit cbb6221

Please sign in to comment.