From 97e21e68b64c65de7ae4e86291d93573e5e92396 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:01:05 +0700 Subject: [PATCH] increasing counter when new report arrives --- .../kotlin/chat/simplex/common/model/ChatModel.kt | 13 ++++++++++++- .../kotlin/chat/simplex/common/model/SimpleXAPI.kt | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 1f83d7d68e..320697d6ad 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 @@ -799,8 +799,19 @@ object ChatModel { changeUnreadCounterNoContentTag(rhId, user, -by) } + fun increaseGroupReportsCounter(rhId: Long?, chatId: ChatId) { + val i = getChatIndex(rhId, chatId) + if (i >= 0) { + val chat = chats.value[i] + chats[i] = chat.copy( + chatStats = chat.chatStats.copy( + reportsCount = chat.chatStats.reportsCount + 1 + ) + ) + } + } + fun decreaseGroupReportsCounter(rhId: Long?, chatId: ChatId, wasArchived: Boolean) { - return val i = getChatIndex(rhId, chatId) if (i >= 0) { val chat = chats.value[i] 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 f4d2921f4a..bce7860a46 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 @@ -2479,6 +2479,10 @@ object ChatController { if (active(r.user)) { withChats { addChatItem(rhId, cInfo, cItem) + val isActiveReport = cItem.isReport && !cItem.isDeletedContent && cItem.meta.itemDeleted == null + if (isActiveReport) { + increaseGroupReportsCounter(rhId, cInfo.id) + } } withReportsChatsIfOpen { if (cItem.isReport) {