Fixed last updated time not displayed for empty chat room
This commit is contained in:
parent
f428a170c5
commit
ee4083389b
1 changed files with 16 additions and 13 deletions
|
@ -322,6 +322,13 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatLastMessage(msg: ChatMessage?) {
|
private fun formatLastMessage(msg: ChatMessage?) {
|
||||||
|
val lastUpdateTime = chatRoom.lastUpdateTime
|
||||||
|
viewModelScope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
lastUpdate.postValue(TimestampUtils.toString(lastUpdateTime, true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val builder = SpannableStringBuilder()
|
val builder = SpannableStringBuilder()
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
lastMessageText.value = builder
|
lastMessageText.value = builder
|
||||||
|
@ -348,13 +355,6 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
|
||||||
|
|
||||||
builder.trim()
|
builder.trim()
|
||||||
lastMessageText.value = builder
|
lastMessageText.value = builder
|
||||||
|
|
||||||
val lastUpdateTime = chatRoom.lastUpdateTime
|
|
||||||
viewModelScope.launch {
|
|
||||||
withContext(Dispatchers.IO) {
|
|
||||||
lastUpdate.postValue(TimestampUtils.toString(lastUpdateTime, true))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRemoteAddress(): Address? {
|
fun getRemoteAddress(): Address? {
|
||||||
|
@ -422,21 +422,24 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateParticipants() {
|
private fun updateParticipants() {
|
||||||
peerSipUri.value = if (oneToOneChatRoom && !basicChatRoom)
|
val participants = chatRoom.participants
|
||||||
chatRoom.participants.firstOrNull()?.address?.asStringUriOnly()
|
peerSipUri.value = if (oneToOneChatRoom && !basicChatRoom) {
|
||||||
|
participants.firstOrNull()?.address?.asStringUriOnly()
|
||||||
?: chatRoom.peerAddress.asStringUriOnly()
|
?: chatRoom.peerAddress.asStringUriOnly()
|
||||||
else chatRoom.peerAddress.asStringUriOnly()
|
} else {
|
||||||
|
chatRoom.peerAddress.asStringUriOnly()
|
||||||
|
}
|
||||||
|
|
||||||
oneParticipantOneDevice = oneToOneChatRoom &&
|
oneParticipantOneDevice = oneToOneChatRoom &&
|
||||||
chatRoom.me?.devices?.size == 1 &&
|
chatRoom.me?.devices?.size == 1 &&
|
||||||
chatRoom.participants.firstOrNull()?.devices?.size == 1
|
participants.firstOrNull()?.devices?.size == 1
|
||||||
|
|
||||||
addressToCall = if (basicChatRoom)
|
addressToCall = if (basicChatRoom)
|
||||||
chatRoom.peerAddress
|
chatRoom.peerAddress
|
||||||
else
|
else
|
||||||
chatRoom.participants.firstOrNull()?.address
|
participants.firstOrNull()?.address
|
||||||
|
|
||||||
onlyParticipantOnlyDeviceAddress = chatRoom.participants.firstOrNull()?.devices?.firstOrNull()?.address
|
onlyParticipantOnlyDeviceAddress = participants.firstOrNull()?.devices?.firstOrNull()?.address
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUnreadMessageCount() {
|
private fun updateUnreadMessageCount() {
|
||||||
|
|
Loading…
Reference in a new issue