Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit c1c8563

Browse files
authored
Merge pull request #1778 from RocketChat/show-stripped-markdown-on-chats-list
[IMPROVEMENT] Show last message on chats list with stripped markdown syntax
2 parents 09c179f + df08934 commit c1c8563

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

app/src/main/java/chat/rocket/android/chatrooms/adapter/RoomViewHolder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import chat.rocket.common.model.RoomType
1111
import chat.rocket.common.model.UserStatus
1212
import kotlinx.android.synthetic.main.item_chat.view.*
1313
import kotlinx.android.synthetic.main.unread_messages_badge.view.*
14+
import ru.noties.markwon.Markwon
1415

1516
class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit) : ViewHolder<RoomItemHolder>(itemView) {
1617

@@ -32,7 +33,7 @@ class RoomViewHolder(itemView: View, private val listener: (RoomUiModel) -> Unit
3233

3334
if (room.lastMessage != null) {
3435
text_last_message.isVisible = true
35-
text_last_message.text = room.lastMessage
36+
text_last_message.text = Markwon.markdown(context, room.lastMessage.toString()).toString()
3637
} else {
3738
text_last_message.isGone = true
3839
}

app/src/main/java/chat/rocket/android/helper/MessageParser.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class MessageParser @Inject constructor(
115115
}
116116

117117
class StrongEmphasisVisitor : AbstractVisitor() {
118+
118119
override fun visit(strongEmphasis: StrongEmphasis) {
119120
if (strongEmphasis.openingDelimiter == "__" && strongEmphasis.firstChild != null) {
120121
val child = strongEmphasis.firstChild
@@ -145,7 +146,7 @@ class MessageParser @Inject constructor(
145146

146147
var offset = 0
147148
mentions.forEach {
148-
val mentionMe = it == currentUser || it == "@all" || it == "@here"
149+
val mentionMe = it == "@$currentUser" || it == "@all" || it == "@here"
149150
offset = text.indexOf(string = it, startIndex = offset, ignoreCase = false)
150151
while (offset > -1) {
151152
val textColor = if (mentionMe) myselfTextColor else othersTextColor

0 commit comments

Comments
 (0)