Display last message timestamp in conversations list instead of chat room last updated timestamp

This commit is contained in:
Sylvain Berfini 2025-06-05 10:28:58 +02:00
parent 5f552e5d82
commit f2d8eea298

View file

@ -349,12 +349,27 @@ class ConversationModel
message.addListener(chatMessageListener) message.addListener(chatMessageListener)
lastMessage = message lastMessage = message
} }
val timestamp = message.time
val humanReadableTimestamp = when {
TimestampUtils.isToday(timestamp) -> {
TimestampUtils.timeToString(timestamp)
}
TimestampUtils.isYesterday(timestamp) -> {
AppUtils.getString(R.string.yesterday)
}
else -> {
TimestampUtils.toString(timestamp, onlyDate = true)
}
}
dateTime.postValue(humanReadableTimestamp)
} else { } else {
lastMessage = null lastMessage = null
lastMessageTextSender.postValue("") lastMessageTextSender.postValue("")
lastMessageContentIcon.postValue(0) lastMessageContentIcon.postValue(0)
lastMessageText.postValue(SpannableStringBuilder("").toSpannable()) lastMessageText.postValue(SpannableStringBuilder("").toSpannable())
isLastMessageOutgoing.postValue(false) isLastMessageOutgoing.postValue(false)
dateTime.postValue("")
Log.w("$TAG No last message to display for conversation [$id]") Log.w("$TAG No last message to display for conversation [$id]")
} }
} }
@ -362,18 +377,6 @@ class ConversationModel
@WorkerThread @WorkerThread
private fun updateLastUpdatedTime() { private fun updateLastUpdatedTime() {
val timestamp = chatRoom.lastUpdateTime val timestamp = chatRoom.lastUpdateTime
val humanReadableTimestamp = when {
TimestampUtils.isToday(timestamp) -> {
TimestampUtils.timeToString(chatRoom.lastUpdateTime)
}
TimestampUtils.isYesterday(timestamp) -> {
AppUtils.getString(R.string.yesterday)
}
else -> {
TimestampUtils.toString(chatRoom.lastUpdateTime, onlyDate = true)
}
}
dateTime.postValue(humanReadableTimestamp)
lastUpdateTime.postValue(timestamp) lastUpdateTime.postValue(timestamp)
} }