Commit c9c14653 authored by Lucio Maciel's avatar Lucio Maciel

Fix duplicate last message on channels list

parent 9497d79d
...@@ -9,6 +9,7 @@ import android.view.ViewGroup ...@@ -9,6 +9,7 @@ import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.helper.UrlHelper import chat.rocket.android.helper.UrlHelper
import chat.rocket.android.util.extensions.content
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.setVisible import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.textContent import chat.rocket.android.util.extensions.textContent
...@@ -67,16 +68,16 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -67,16 +68,16 @@ class ChatRoomsAdapter(private val context: Context,
} }
private fun bindName(chatRoom: ChatRoom, textView: TextView) { private fun bindName(chatRoom: ChatRoom, textView: TextView) {
textView.textContent = chatRoom.name textView.content = chatRoom.name
} }
private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) { private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) {
val lastMessage = chatRoom.lastMessage val lastMessage = chatRoom.lastMessage
if (lastMessage != null) { if (lastMessage != null) {
val localDateTime = DateTimeHelper.getLocalDateTime(lastMessage.timestamp) val localDateTime = DateTimeHelper.getLocalDateTime(lastMessage.timestamp)
textView.textContent = DateTimeHelper.getDate(localDateTime, context) textView.content = DateTimeHelper.getDate(localDateTime, context)
} else { } else {
textView.textContent = "" textView.content = ""
} }
} }
...@@ -88,16 +89,18 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -88,16 +89,18 @@ class ChatRoomsAdapter(private val context: Context,
val senderUsername = lastMessageSender.username val senderUsername = lastMessageSender.username
when (senderUsername) { when (senderUsername) {
chatRoom.name -> { chatRoom.name -> {
textView.textContent = message textView.content = message
} }
// TODO Change to MySelf // TODO Change to MySelf
// chatRoom.user?.username -> { // chatRoom.user?.username -> {
// holder.lastMessage.textContent = context.getString(R.string.msg_you) + ": $message" // holder.lastMessage.textContent = context.getString(R.string.msg_you) + ": $message"
// } // }
else -> { else -> {
textView.textContent = "@$senderUsername: $message" textView.content = "@$senderUsername: $message"
} }
} }
} else {
textView.content = ""
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment