wip
This commit is contained in:
parent
f489425b99
commit
f8030ed60e
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue