ios: mark chat non deleted only on send/receive (keep chatDeleted flag on open) (#4659)

* ios: navigation to delete chat working for group members

* modify

* Revert "modify"

This reverts commit fc811bbb84.

* don't mark non deleted on open, mark on send

* simplify

---------

Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
Diogo
2024-08-12 15:49:34 +01:00
committed by GitHub
parent 02c404593c
commit 9871ebb3b1
3 changed files with 7 additions and 15 deletions

View File

@@ -328,6 +328,12 @@ final class ChatModel: ObservableObject {
// }
func addChatItem(_ cInfo: ChatInfo, _ cItem: ChatItem) {
// mark chat non deleted
if case let .direct(contact) = cInfo, contact.chatDeleted {
var updatedContact = contact
updatedContact.chatDeleted = false
updateContact(updatedContact)
}
// update previews
if let i = getChatIndex(cInfo.id) {
chats[i].chatItems = switch cInfo {

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))")
@@ -1778,11 +1772,6 @@ func processReceivedMsg(_ res: ChatResponse) async {
let cItem = aChatItem.chatItem
await MainActor.run {
if active(user) {
if case let .direct(contact) = cInfo, contact.chatDeleted {
var updatedContact = contact
updatedContact.chatDeleted = false
m.updateContact(updatedContact)
}
m.addChatItem(cInfo, cItem)
} else if cItem.isRcvNew && cInfo.ntfsEnabled {
m.increaseUnreadCounter(user: user)

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
}