mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-29 05:29:08 +00:00
fixed message grouping and time show
This commit is contained in:
+15
-5
@@ -1197,7 +1197,7 @@ fun BoxWithConstraintsScope.ChatItemsList(
|
||||
// memberConnected events and deleted items are aggregated at the last chat item in a row, see ChatItemView
|
||||
} else {
|
||||
val (prevHidden, prevItem) = chatModel.getPrevShownChatItem(currIndex, ciCategory)
|
||||
val itemSeparation = getItemSeparation(cItem, prevItem)
|
||||
val itemSeparation = getItemSeparation(cItem, prevItem, nextItem)
|
||||
val range = chatViewItemsRange(currIndex, prevHidden)
|
||||
if (revealed.value && range != null) {
|
||||
reversedChatItems.subList(range.first, range.last + 1).forEachIndexed { index, ci ->
|
||||
@@ -1899,8 +1899,8 @@ private fun handleForwardConfirmation(
|
||||
)
|
||||
}
|
||||
|
||||
private fun getItemSeparation(chatItem: ChatItem, nextItem: ChatItem?): ItemSeparation {
|
||||
if (nextItem == null) {
|
||||
private fun getItemSeparation(chatItem: ChatItem, prevItem: ChatItem?, nextItem: ChatItem?): ItemSeparation {
|
||||
if (prevItem == null) {
|
||||
return ItemSeparation(
|
||||
timestamp = true,
|
||||
largeGap = false,
|
||||
@@ -1908,15 +1908,25 @@ private fun getItemSeparation(chatItem: ChatItem, nextItem: ChatItem?): ItemSepa
|
||||
)
|
||||
}
|
||||
|
||||
if (nextItem == null) {
|
||||
return ItemSeparation(
|
||||
timestamp = true,
|
||||
largeGap = false,
|
||||
date = if (getTimestampDateText(chatItem.meta.itemTs) != getTimestampDateText(prevItem.meta.itemTs)) chatItem.meta.itemTs else null
|
||||
)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Log.e(TAG, "getItemSeparation: next: ${nextItem.text} prev: ${prevItem.text} curr: ${chatItem.text}")
|
||||
|
||||
return ItemSeparation(
|
||||
timestamp = largeGap || chatItem.meta.timestampText != nextItem.meta.timestampText,
|
||||
timestamp = largeGap || nextItem.meta.timestampText != chatItem.meta.timestampText,
|
||||
largeGap = largeGap,
|
||||
date = if (getTimestampDateText(chatItem.meta.itemTs) != getTimestampDateText(nextItem.meta.itemTs)) chatItem.meta.itemTs else null
|
||||
date = if (getTimestampDateText(chatItem.meta.itemTs) != getTimestampDateText(prevItem.meta.itemTs)) chatItem.meta.itemTs else null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user