From 63c28c64d13297a65def02c05bf4bf7b1fc8b8ea Mon Sep 17 00:00:00 2001 From: Diogo Date: Fri, 20 Sep 2024 18:10:59 +0100 Subject: [PATCH] refactor --- .../kotlin/chat/simplex/common/model/ChatModel.kt | 4 ---- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 6 +++++- 2 files changed, 5 insertions(+), 5 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 1bd5361273..914bc66e2c 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 @@ -2335,10 +2335,6 @@ sealed class CIDirection { is LocalSnd -> true is LocalRcv -> false } - - fun sameDirection(dir: CIDirection): Boolean { - return if (dir is GroupRcv && this is GroupRcv) this.groupMember.groupMemberId == dir.groupMember.groupMemberId else this.sent == dir.sent - } } @Serializable 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 90d0999d06..91a4eb79bd 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 @@ -24,6 +24,7 @@ import androidx.compose.ui.text.* import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.* import chat.simplex.common.model.* +import chat.simplex.common.model.CIDirection.GroupRcv import chat.simplex.common.model.ChatController.appPrefs import chat.simplex.common.model.ChatModel.controller import chat.simplex.common.model.ChatModel.withChats @@ -1906,7 +1907,10 @@ private fun getItemSeparation(chatItem: ChatItem, nextItem: ChatItem?): ItemSepa ) } - val largeGap = !chatItem.chatDir.sameDirection(nextItem.chatDir) || (abs(nextItem.meta.createdAt.epochSeconds - chatItem.meta.createdAt.epochSeconds) >= 60) + val sameMemberAndDirection = if (nextItem.chatDir is GroupRcv && chatItem.chatDir is GroupRcv) { + chatItem.chatDir.groupMember.groupMemberId == nextItem.chatDir.groupMember.groupMemberId + } else chatItem.chatDir.sent == nextItem.chatDir.sent + val largeGap = !sameMemberAndDirection || (abs(nextItem.meta.createdAt.epochSeconds - chatItem.meta.createdAt.epochSeconds) >= 60) return ItemSeparation( timestamp = largeGap || chatItem.meta.timestampText != nextItem.meta.timestampText,