ios: use agent connection id as key for network statuses map (#1808)

This commit is contained in:
JRoberts
2023-01-20 17:35:39 +04:00
committed by GitHub
parent cb5f26d354
commit 980c7a9ddd
4 changed files with 19 additions and 16 deletions
+6 -6
View File
@@ -1017,7 +1017,7 @@ func processReceivedMsg(_ res: ChatResponse) async {
m.removeChat(contact.activeConn.id)
NtfManager.shared.notifyContactConnected(user, contact)
}
m.updateContactNetworkStatus(contact, .connected)
m.setContactNetworkStatus(contact, .connected)
case let .contactConnecting(user, contact):
if active(user) && contact.directOrUsed {
m.updateContact(contact)
@@ -1049,9 +1049,9 @@ func processReceivedMsg(_ res: ChatResponse) async {
}
m.removeChat(mergedContact.id)
}
case let .contactsSubscribed(_, _, contactRefs):
case let .contactsSubscribed(_, contactRefs):
updateContactsStatus(contactRefs, status: .connected)
case let .contactsDisconnected(_, _, contactRefs):
case let .contactsDisconnected(_, contactRefs):
updateContactsStatus(contactRefs, status: .disconnected)
case let .contactSubError(user, contact, chatError):
if active(user) {
@@ -1066,7 +1066,7 @@ func processReceivedMsg(_ res: ChatResponse) async {
if let err = sub.contactError {
processContactSubError(sub.contact, err)
} else {
m.updateContactNetworkStatus(sub.contact, .connected)
m.setContactNetworkStatus(sub.contact, .connected)
}
}
case let .newChatItem(user, aChatItem):
@@ -1285,7 +1285,7 @@ func chatItemSimpleUpdate(_ aChatItem: AChatItem) {
func updateContactsStatus(_ contactRefs: [ContactRef], status: NetworkStatus) {
let m = ChatModel.shared
for c in contactRefs {
m.networkStatuses[c.connId] = status
m.networkStatuses[c.agentConnId] = status
}
}
@@ -1297,7 +1297,7 @@ func processContactSubError(_ contact: Contact, _ chatError: ChatError) {
case .errorAgent(agentError: .SMP(smpErr: .AUTH)): err = "contact deleted"
default: err = String(describing: chatError)
}
m.updateContactNetworkStatus(contact, .error(err))
m.setContactNetworkStatus(contact, .error(err))
}
func refreshCallInvitations() throws {