ios: navigation to delete chat working for group members

This commit is contained in:
Diogo Cunha
2024-08-12 01:02:22 +01:00
parent e20a4e54c3
commit 4a31dcd319
3 changed files with 7 additions and 11 deletions

View File

@@ -340,13 +340,7 @@ func loadChat(chat: Chat, search: String = "") {
m.chatItemStatuses = [:]
im.reversedChatItems = []
let chat = try apiGetChat(type: cInfo.chatType, id: cInfo.apiId, search: search)
if case let .direct(contact) = chat.chatInfo, !cInfo.chatDeleted, chat.chatInfo.chatDeleted {
var updatedContact = contact
updatedContact.chatDeleted = false
m.updateContact(updatedContact)
} else {
m.updateChatInfo(chat.chatInfo)
}
m.updateChatInfo(chat.chatInfo)
im.reversedChatItems = chat.chatItems.reversed()
} catch let error {
logger.error("loadChat error: \(responseError(error))")

View File

@@ -306,7 +306,12 @@ struct ChatView: View {
let (stats, _) = try await apiContactInfo(chat.chatInfo.apiId)
await MainActor.run {
if let s = stats {
chatModel.updateContactConnectionStats(contact, s)
var updatedContact = contact
if contact.chatDeleted {
updatedContact.chatDeleted = false
}
chatModel.updateContactConnectionStats(updatedContact, s)
}
}
} catch let error {

View File

@@ -82,9 +82,6 @@ struct ContactListNavLink: View {
Button {
Task {
await MainActor.run {
var updatedContact = contact
updatedContact.chatDeleted = false
ChatModel.shared.updateContact(updatedContact)
dismissAllSheets(animated: true) {
ChatModel.shared.chatId = contact.id
}