Commit ea6006ba authored by Leonardo Aramaki's avatar Leonardo Aramaki

Use username on the reply/citation markdown

parent 6b2bdf3b
......@@ -194,7 +194,7 @@ class ChatRoomPresenter @Inject constructor(
}
} catch (ex: Exception) {
Timber.d(ex, "Error uploading file")
when(ex) {
when (ex) {
is RocketChatException -> view.showMessage(ex)
else -> view.showGenericErrorMessage()
}
......@@ -336,33 +336,28 @@ class ChatRoomPresenter @Inject constructor(
val me: Myself? = try {
retryIO("me()") { client.me() } //TODO: Cache this and use an interactor
} catch (ex: Exception) {
Timber.d(ex, "Error getting myself info.")
ex.printStackTrace()
Timber.e(ex)
null
}
message?.let { m ->
val id = m.id
val username = m.sender?.username
val user = "@" + if (settings.useRealName()) m.sender?.name
?: m.sender?.username else m.sender?.username
val mention = if (mentionAuthor && me?.username != username) user else ""
val type = roomTypeOf(roomType)
val room = when (type) {
is RoomType.Channel -> "channel"
is RoomType.DirectMessage -> "direct"
is RoomType.PrivateGroup -> "group"
is RoomType.Livechat -> "livechat"
is RoomType.Custom -> "custom" //TODO: put appropriate callback string here.
}
message?.let { msg ->
val id = msg.id
val username = msg.sender?.username ?: ""
val mention = if (mentionAuthor && me?.username != username) username else ""
val room = if (roomTypeOf(roomType) is RoomType.DirectMessage) username else roomType
view.showReplyingAction(
username = user,
replyMarkdown = "[ ]($currentServer/$room/$roomName?msg=$id) $mention ",
username = getDisplayName(msg.sender),
replyMarkdown = "[ ]($currentServer/$roomType/$room?msg=$id) $mention ",
quotedMessage = mapper.map(message).last().preview?.message ?: ""
)
}
}
}
private fun getDisplayName(user: SimpleUser?): String {
val username = user?.username ?: ""
return if (settings.useRealName()) user?.name ?: username else username
}
/**
* Copy message to clipboard.
*
......
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