Commit df089349 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Show last message on chats list with stripped markdown syntax

parent 71410e16
......@@ -11,6 +11,7 @@ import chat.rocket.common.model.RoomType
import chat.rocket.common.model.UserStatus
import kotlinx.android.synthetic.main.item_chat.view.*
import kotlinx.android.synthetic.main.unread_messages_badge.view.*
import ru.noties.markwon.Markwon
class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit) : ViewHolder<RoomItemHolder>(itemView) {
......@@ -32,7 +33,7 @@ class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit
if (room.lastMessage != null) {
text_last_message.isVisible = true
text_last_message.text = room.lastMessage
text_last_message.text = Markwon.markdown(context, room.lastMessage.toString()).toString()
} else {
text_last_message.isGone = true
}
......
......@@ -115,6 +115,7 @@ class MessageParser @Inject constructor(
}
class StrongEmphasisVisitor : AbstractVisitor() {
override fun visit(strongEmphasis: StrongEmphasis) {
if (strongEmphasis.openingDelimiter == "__" && strongEmphasis.firstChild != null) {
val child = strongEmphasis.firstChild
......@@ -145,7 +146,7 @@ class MessageParser @Inject constructor(
var offset = 0
mentions.forEach {
val mentionMe = it == currentUser || it == "@all" || it == "@here"
val mentionMe = it == "@$currentUser" || it == "@all" || it == "@here"
offset = text.indexOf(string = it, startIndex = offset, ignoreCase = false)
while (offset > -1) {
val textColor = if (mentionMe) myselfTextColor else othersTextColor
......
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