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 b68d098f9..538959258 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 @@ -494,10 +494,11 @@ object ChatModel { } // this function analyses "connected" events and assumes that each member will be there only once - fun getConnectedMemberNames(cItem: ChatItem): Pair> { + fun getConnectedMemberNames(cItem: ChatItem): Triple, String?> { var count = 0 val ns = mutableListOf() var idx = getChatItemIndexOrNull(cItem) + var lastNonConnectedEvent: String? = null if (cItem.mergeCategory != null && idx != null) { val reversedChatItems = chatItems.asReversed() while (idx < reversedChatItems.size) { @@ -506,12 +507,14 @@ object ChatModel { val m = ci.memberConnected if (m != null) { ns.add(m.displayName) + } else if (count == 0) { + lastNonConnectedEvent = if (ci.memberDisplayName != null) ci.memberDisplayName + " " + ci.text else ci.text } count++ idx++ } } - return count to ns + return Triple(count, ns, lastNonConnectedEvent) } // returns the index of the passed item and the next item (it has smaller index) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt index 549f5f2f5..1786b8576 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt @@ -332,7 +332,7 @@ fun ChatItemView( } fun mergedGroupEventText(chatItem: ChatItem): String? { - val (count, ns) = chatModel.getConnectedMemberNames(chatItem) + val (count, ns, lastNonConnectedEvent) = chatModel.getConnectedMemberNames(chatItem) val members = when { ns.size == 1 -> String.format(generalGetString(MR.strings.rcv_group_event_1_member_connected), ns[0]) ns.size == 2 -> String.format(generalGetString(MR.strings.rcv_group_event_2_members_connected), ns[0], ns[1]) @@ -342,6 +342,8 @@ fun ChatItemView( } return if (count <= 1) { null + } else if (lastNonConnectedEvent != null) { + lastNonConnectedEvent + " " + generalGetString(MR.strings.rcv_group_and_other_events).format(count - ns.size) } else if (ns.isEmpty()) { generalGetString(MR.strings.rcv_group_events_count).format(count) } else if (count > ns.size) {