Commit debc714e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Fix quoted message not displaying

parent 5cf2fe1f
...@@ -209,10 +209,10 @@ class ChatRoomAdapter( ...@@ -209,10 +209,10 @@ class ChatRoomAdapter(
message.apply { message.apply {
when (item.itemId) { when (item.itemId) {
R.id.action_message_reply -> { R.id.action_message_reply -> {
presenter?.citeMessage(roomType, id, true) presenter?.citeMessage(roomName, roomType, id, true)
} }
R.id.action_message_quote -> { R.id.action_message_quote -> {
presenter?.citeMessage(roomType, id, false) presenter?.citeMessage(roomName, roomType, id, false)
} }
R.id.action_message_copy -> { R.id.action_message_copy -> {
presenter?.copyMessage(id) presenter?.copyMessage(id)
......
...@@ -211,8 +211,8 @@ class ChatRoomPresenter @Inject constructor( ...@@ -211,8 +211,8 @@ class ChatRoomPresenter @Inject constructor(
isTemporary = true isTemporary = true
) )
try { try {
val message = client.sendMessage(id, chatRoomId, text)
messagesRepository.save(newMessage) messagesRepository.save(newMessage)
val message = client.sendMessage(id, chatRoomId, text)
view.showNewMessage(mapper.map(newMessage, RoomViewModel( view.showNewMessage(mapper.map(newMessage, RoomViewModel(
roles = chatRoles, isBroadcast = chatIsBroadcast))) roles = chatRoles, isBroadcast = chatIsBroadcast)))
message message
...@@ -413,7 +413,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -413,7 +413,7 @@ class ChatRoomPresenter @Inject constructor(
* @param messageId The id of the message to make citation for. * @param messageId The id of the message to make citation for.
* @param mentionAuthor true means the citation is a reply otherwise it's a quote. * @param mentionAuthor true means the citation is a reply otherwise it's a quote.
*/ */
fun citeMessage(roomType: String, messageId: String, mentionAuthor: Boolean) { fun citeMessage(roomName: String, roomType: String, messageId: String, mentionAuthor: Boolean) {
launchUI(strategy) { launchUI(strategy) {
val message = messagesRepository.getById(messageId) val message = messagesRepository.getById(messageId)
val me: Myself? = try { val me: Myself? = try {
...@@ -426,10 +426,17 @@ class ChatRoomPresenter @Inject constructor( ...@@ -426,10 +426,17 @@ class ChatRoomPresenter @Inject constructor(
val id = msg.id val id = msg.id
val username = msg.sender?.username ?: "" val username = msg.sender?.username ?: ""
val mention = if (mentionAuthor && me?.username != username) "@$username" else "" val mention = if (mentionAuthor && me?.username != username) "@$username" else ""
val room = if (roomTypeOf(roomType) is RoomType.DirectMessage) username else roomType val room = if (roomTypeOf(roomType) is RoomType.DirectMessage) username else roomName
val chatRoomType = when(roomTypeOf(roomType)) {
is RoomType.DirectMessage -> "direct"
is RoomType.PrivateGroup -> "group"
is RoomType.Channel -> "channel"
is RoomType.Livechat -> "livechat"
else -> "custom"
}
view.showReplyingAction( view.showReplyingAction(
username = getDisplayName(msg.sender), username = getDisplayName(msg.sender),
replyMarkdown = "[ ]($currentServer/$roomType/$room?msg=$id) $mention ", replyMarkdown = "[ ]($currentServer/$chatRoomType/$room?msg=$id) $mention ",
quotedMessage = mapper.map(message, RoomViewModel(roles = chatRoles, quotedMessage = mapper.map(message, RoomViewModel(roles = chatRoles,
isBroadcast = chatIsBroadcast)).last().preview?.message ?: "" isBroadcast = chatIsBroadcast)).last().preview?.message ?: ""
) )
......
...@@ -50,6 +50,7 @@ class MessageService : JobService() { ...@@ -50,6 +50,7 @@ class MessageService : JobService() {
val client = connectionManager.client val client = connectionManager.client
temporaryMessages.forEach { message -> temporaryMessages.forEach { message ->
try { try {
messageRepository.save(message.copy(isTemporary = false))
client.sendMessage( client.sendMessage(
message = message.message, message = message.message,
messageId = message.id, messageId = message.id,
...@@ -58,7 +59,6 @@ class MessageService : JobService() { ...@@ -58,7 +59,6 @@ class MessageService : JobService() {
attachments = message.attachments, attachments = message.attachments,
alias = message.senderAlias alias = message.senderAlias
) )
messageRepository.save(message.copy(isTemporary = false))
Timber.d("Sent scheduled message given by id: ${message.id}") Timber.d("Sent scheduled message given by id: ${message.id}")
} catch (ex: RocketChatException) { } catch (ex: RocketChatException) {
Timber.e(ex) Timber.e(ex)
......
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