ui: fix possible suspect for race condition on accept contact (#6121)

This commit is contained in:
spaced4ndy
2025-07-28 16:51:37 +01:00
committed by GitHub
parent 7988463a47
commit 69461c2257
3 changed files with 9 additions and 5 deletions
@@ -707,7 +707,6 @@ fun acceptContactRequest(
withBGApi {
inProgress?.value = true
val contact = chatModel.controller.apiAcceptContactRequest(rhId, incognito, contactRequestId)
inProgress?.value = false
if (contact != null && isCurrentUser) {
val chat = Chat(remoteHostId = rhId, ChatInfo.Direct(contact), listOf())
withContext(Dispatchers.Main) {
@@ -716,9 +715,12 @@ fun acceptContactRequest(
} else {
chatModel.chatsContext.replaceChat(rhId, contactRequestChatId(contactRequestId), chat)
}
inProgress?.value = false
}
chatModel.setContactNetworkStatus(contact, NetworkStatus.Connected())
close?.invoke(chat)
} else {
inProgress?.value = false
}
}
}