From 473fdedf239337a7085651312bb01cf5afd89d4c Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:03:28 +0700 Subject: [PATCH] refactor --- .../kotlin/chat/simplex/common/model/ChatModel.kt | 2 ++ .../kotlin/chat/simplex/common/model/SimpleXAPI.kt | 6 ++---- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 6 ++---- 3 files changed, 6 insertions(+), 8 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 320697d6ad..811ec33e5d 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 @@ -2392,6 +2392,8 @@ data class ChatItem ( else -> false } + val isActiveReport: Boolean get() = isReport && !isDeletedContent && meta.itemDeleted == null + val canBeDeletedForSelf: Boolean get() = (content.msgContent != null && !meta.isLive) || meta.itemDeleted != null || isDeletedContent || mergeCategory != null || showLocalDelete 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 bce7860a46..50b6a44f3d 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,8 +2479,7 @@ object ChatController { if (active(r.user)) { withChats { addChatItem(rhId, cInfo, cItem) - val isActiveReport = cItem.isReport && !cItem.isDeletedContent && cItem.meta.itemDeleted == null - if (isActiveReport) { + if (cItem.isActiveReport) { increaseGroupReportsCounter(rhId, cInfo.id) } } @@ -2614,8 +2613,7 @@ object ChatController { CIDeleted.Deleted(Clock.System.now()) } upsertChatItem(rhId, cInfo, cItem.copy(meta = cItem.meta.copy(itemDeleted = deleted))) - val isActiveReport = cItem.isReport && !cItem.isDeletedContent && cItem.meta.itemDeleted == null - if (isActiveReport) { + if (cItem.isActiveReport) { decreaseGroupReportsCounter(rhId, cInfo.id, wasModerated) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 89f66e0a4e..7c2b38c73c 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -398,8 +398,7 @@ fun ChatView( removeChatItem(chatRh, chatInfo, deletedChatItem) } val deletedItem = deleted.deletedChatItem.chatItem - val isActiveReport = deletedItem.isReport == true && !deletedItem.isDeletedContent && deletedItem.meta.itemDeleted == null - if (isActiveReport) { + if (deletedItem.isActiveReport) { decreaseGroupReportsCounter(chatRh, chatInfo.id, toChatItem != null) } } @@ -2334,8 +2333,7 @@ private fun deleteMessages(chatRh: Long?, chatInfo: ChatInfo, itemIds: List