From d1f704d1602471f82e5084d66650ec80c6fdc7b6 Mon Sep 17 00:00:00 2001 From: Diogo Date: Mon, 12 Aug 2024 16:50:36 +0100 Subject: [PATCH] multiplatform: mark chat non deleted only on send/receive (keep chatDeleted flag on open) (#4664) --- .../kotlin/chat/simplex/common/model/ChatModel.kt | 5 +++++ .../kotlin/chat/simplex/common/model/SimpleXAPI.kt | 6 ------ .../simplex/common/views/contacts/ContactListNavView.kt | 3 --- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index e5fb314cb6..927fa4d543 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -275,6 +275,11 @@ object ChatModel { } } suspend fun addChatItem(rhId: Long?, cInfo: ChatInfo, cItem: ChatItem) { + // mark chat non deleted + if (cInfo is ChatInfo.Direct && cInfo.chatDeleted) { + val updatedContact = cInfo.contact.copy(chatDeleted = false) + updateContact(rhId, updatedContact) + } // update previews val i = getChatIndex(rhId, cInfo.id) val chat: Chat diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt index 8e7543d12c..8bf93d0407 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt @@ -2136,12 +2136,6 @@ object ChatController { val cInfo = r.chatItem.chatInfo val cItem = r.chatItem.chatItem if (active(r.user)) { - if (cInfo is ChatInfo.Direct && cInfo.chatDeleted) { - val updatedContact = cInfo.contact.copy(chatDeleted = false) - withChats { - updateContact(rhId, updatedContact) - } - } withChats { addChatItem(rhId, cInfo, cItem) } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/contacts/ContactListNavView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/contacts/ContactListNavView.kt index 05e693b7c2..711fb1377d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/contacts/ContactListNavView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/contacts/ContactListNavView.kt @@ -61,9 +61,6 @@ fun ContactListNavLinkView(chat: Chat, nextChatSelected: State, showDel ContactType.CHAT_DELETED -> { withApi { openChat(rhId, chat.chatInfo, chatModel) - withChats { - updateContact(rhId, chat.chatInfo.contact.copy(chatDeleted = false)) - } ModalManager.start.closeModals() } }