调整成30分钟一次时间分割显示;最新的信息不显示时间
This commit is contained in:
@@ -3,6 +3,7 @@ package com.aiosman.riderpro.ui.chat
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.Crossfade
|
||||
@@ -509,14 +510,14 @@ fun ChatInput(
|
||||
fun groupMessagesByTime(chatList: List<ChatItem>, viewModel: ChatViewModel): List<ChatItem> {
|
||||
for (i in chatList.indices) { // Iterate in normal order
|
||||
if (i == 0) {
|
||||
viewModel.showTimestampMap[chatList[i].msgId] = true
|
||||
chatList[i].showTimeDivider = true
|
||||
viewModel.showTimestampMap[chatList[i].msgId] = false
|
||||
chatList[i].showTimeDivider = false
|
||||
continue
|
||||
}
|
||||
val currentMessage = chatList[i]
|
||||
val timeDiff = currentMessage.timestamp - chatList[i - 1].timestamp
|
||||
// 时间间隔大于 3 分钟,显示时间戳
|
||||
if (-timeDiff > 3 * 60 * 1000) {
|
||||
if (-timeDiff > 30 * 60 * 1000) {
|
||||
viewModel.showTimestampMap[currentMessage.msgId] = true
|
||||
currentMessage.showTimeDivider = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user