This commit is contained in:
Woit 2024-12-04 16:03:20 +01:00
parent f489425b99
commit f8030ed60e
2 changed files with 20 additions and 2 deletions

View file

@ -6,7 +6,7 @@ struct Contact: Identifiable {
let contactJid: String
private let nickname: String?
var id: String { contactJid }
var id: String { "\(ownerId)|\(contactJid)" }
var name: String {
if let nickname {

View file

@ -112,7 +112,25 @@ private extension WrapperXMPP {
// Process monalxmpp events
func processEvent(_ notificationName: String, _ object: Any?) {
print(notificationName, object)
switch notificationName {
case kMonalRefresh:
print("refresh?")
case kMonalContactRefresh:
if let mlContact = object as? MLContact {
if let updated = Contact(mlContact), let index = contacts.firstIndex(where: { $0.id == mlContact.id }) {
contacts[index] = updated
}
}
case kMonalContactRemoved:
if let mlContact = object as? MLContact {
contacts = contacts.filter { $0.id != mlContact.id }
}
default:
break
}
}
// Initital monalxmpp db fetch