mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-15 04:30:38 +00:00
ui: fix possible suspect for race condition on accept contact (#6121)
This commit is contained in:
@@ -1617,7 +1617,8 @@ func networkErrorAlert<R>(_ res: APIResult<R>) -> Alert? {
|
||||
}
|
||||
}
|
||||
|
||||
func acceptContactRequest(incognito: Bool, contactRequestId: Int64) async {
|
||||
func acceptContactRequest(incognito: Bool, contactRequestId: Int64, inProgress: Binding<Bool>? = nil) async {
|
||||
await MainActor.run { inProgress?.wrappedValue = true }
|
||||
if let contact = await apiAcceptContactRequest(incognito: incognito, contactReqId: contactRequestId) {
|
||||
let chat = Chat(chatInfo: ChatInfo.direct(contact: contact), chatItems: [])
|
||||
await MainActor.run {
|
||||
@@ -1627,6 +1628,7 @@ func acceptContactRequest(incognito: Bool, contactRequestId: Int64) async {
|
||||
ChatModel.shared.replaceChat(contactRequestChatId(contactRequestId), chat)
|
||||
}
|
||||
NetworkModel.shared.setContactNetworkStatus(contact, .connected)
|
||||
inProgress?.wrappedValue = false
|
||||
}
|
||||
if contact.sndReady {
|
||||
let chatId = chat.id
|
||||
@@ -1636,6 +1638,8 @@ func acceptContactRequest(incognito: Bool, contactRequestId: Int64) async {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await MainActor.run { inProgress?.wrappedValue = false }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user