Commit 0e4b3810 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Shows mentions with @ symbol

parent 92832192
......@@ -9,9 +9,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.dagger.scope.PerFragment
import chat.rocket.android.db.ChatRoomDao
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.db.UserDao
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetCurrentUserInteractor
import chat.rocket.android.server.domain.PermissionsInteractor
import chat.rocket.android.server.domain.SettingsRepository
......
......@@ -126,8 +126,8 @@ class RoomUiModelMapper(
} else {
null
}
val hasMentions = mapMentions(userMentions, groupMentions)
val open = open
val lastMessageMarkdown =
lastMessage?.let { Markwon.markdown(context, it.toString()).toString() }
......@@ -139,6 +139,7 @@ class RoomUiModelMapper(
open = open,
date = timestamp,
unread = unread,
mentions = hasMentions,
alert = isUnread,
lastMessage = lastMessageMarkdown,
status = status,
......@@ -203,5 +204,14 @@ class RoomUiModelMapper(
}
}
private fun mapMentions(userMentions: Long?, groupMentions: Long?): Boolean {
if (userMentions != null && groupMentions != null) {
if (userMentions > 0 || groupMentions > 0) {
return true
}
}
return false
}
private fun mapDate(date: Long?): CharSequence? = date?.localDateTime()?.date(context)
}
......@@ -49,29 +49,19 @@ class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit
text_timestamp.isInvisible = true
}
if (room.unread != null) {
text_total_unread_messages.text = room.unread
if (room.alert) {
if (room.unread == null) text_total_unread_messages.text = "!"
if (room.unread != null) text_total_unread_messages.text = room.unread
if (room.mentions) text_total_unread_messages.text = "@${room.unread}"
text_timestamp.setTextAppearance(context, R.style.ChatList_Timestamp_Unread_TextView)
text_last_message.setTextAppearance(context, R.style.ChatList_LastMessage_Unread_TextView)
text_total_unread_messages.isVisible = true
} else {
text_timestamp.setTextAppearance(context, R.style.ChatList_Timestamp_TextView)
text_last_message.setTextAppearance(context, R.style.ChatList_LastMessage_TextView)
text_total_unread_messages.isInvisible = true
}
context?.let {
if (room.alert || room.unread != null) {
text_timestamp.setTextAppearance(it, R.style.ChatList_Timestamp_Unread_TextView)
text_last_message.setTextAppearance(
it,
R.style.ChatList_LastMessage_Unread_TextView
)
text_total_unread_messages.text = "!"
text_total_unread_messages.isVisible = true
} else {
text_timestamp.setTextAppearance(it, R.style.ChatList_Timestamp_TextView)
text_last_message.setTextAppearance(it, R.style.ChatList_LastMessage_TextView)
text_total_unread_messages.isInvisible = true
}
}
setOnClickListener { listener(room) }
}
}
......
......@@ -12,6 +12,7 @@ data class RoomUiModel(
val date: CharSequence? = null,
val unread: String? = null,
val alert: Boolean = false,
val mentions: Boolean = false,
val lastMessage: CharSequence? = null,
val status: UserStatus? = null,
val username: String? = null,
......
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