Fixed chat room list cell UI glitch during last update time computation

This commit is contained in:
Sylvain Berfini 2022-06-13 15:15:04 +02:00
parent 312ae2eaf0
commit f118ccf049
3 changed files with 4 additions and 8 deletions

View file

@ -130,7 +130,7 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface {
if (chatRoom.participants.isNotEmpty()) { if (chatRoom.participants.isNotEmpty()) {
chatRoom.participants[0].address chatRoom.participants[0].address
} else { } else {
Log.e("[Chat Room] $chatRoom doesn't have any participant in state ${chatRoom.state}!") Log.e("[Chat Room] $chatRoom doesn't have any participant (state ${chatRoom.state})!")
null null
} }
} }
@ -141,6 +141,7 @@ class ChatRoomData(private val chatRoom: ChatRoom) : ContactDataInterface {
private fun formatLastMessage(msg: ChatMessage?) { private fun formatLastMessage(msg: ChatMessage?) {
val lastUpdateTime = chatRoom.lastUpdateTime val lastUpdateTime = chatRoom.lastUpdateTime
lastUpdate.value = "00:00"
coroutineScope.launch { coroutineScope.launch {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
lastUpdate.postValue(TimestampUtils.toString(lastUpdateTime, true)) lastUpdate.postValue(TimestampUtils.toString(lastUpdateTime, true))

View file

@ -295,7 +295,7 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactDataInterf
if (chatRoom.participants.isNotEmpty()) { if (chatRoom.participants.isNotEmpty()) {
chatRoom.participants[0].address chatRoom.participants[0].address
} else { } else {
Log.e("[Chat Room] $chatRoom doesn't have any participant in state ${chatRoom.state}!") Log.e("[Chat Room] $chatRoom doesn't have any participant (state ${chatRoom.state})!")
null null
} }
} }

View file

@ -38,18 +38,13 @@
style="@style/toolbar_small_title_font" style="@style/toolbar_small_title_font"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.6" android:layout_weight="0.8"
android:gravity="center" android:gravity="center"
android:padding="15dp" android:padding="15dp"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:text="@string/chat_room_devices_fragment_title" /> android:text="@string/chat_room_devices_fragment_title" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2" />
</LinearLayout> </LinearLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView