Commit 78b43eec authored by Leonardo Aramaki's avatar Leonardo Aramaki

Check if in a room before adding message replies

parent b9f51766
......@@ -153,7 +153,7 @@ class ChatRoomPresenter @Inject constructor(
if (offset == 0L) {
val localMessages = messagesRepository.getByRoomId(chatRoomId)
val oldMessages = mapper.map(localMessages, RoomViewModel(roles = chatRoles,
isBroadcast = chatIsBroadcast))
isBroadcast = chatIsBroadcast, isRoom = true))
if (oldMessages.isNotEmpty()) {
view.showMessages(oldMessages)
loadMissingMessages()
......@@ -194,7 +194,7 @@ class ChatRoomPresenter @Inject constructor(
}
messagesRepository.saveAll(messages)
view.showMessages(mapper.map(messages, RoomViewModel(roles = chatRoles,
isBroadcast = chatIsBroadcast)))
isBroadcast = chatIsBroadcast, isRoom = true)))
}
fun sendMessage(chatRoomId: String, text: String, messageId: String?) {
......@@ -373,7 +373,7 @@ class ChatRoomPresenter @Inject constructor(
if (messages.result.isNotEmpty()) {
val models = mapper.map(messages.result, RoomViewModel(
roles = chatRoles, isBroadcast = chatIsBroadcast))
roles = chatRoles, isBroadcast = chatIsBroadcast, isRoom = true))
messagesRepository.saveAll(messages.result)
launchUI(strategy) {
......
......@@ -4,5 +4,6 @@ import chat.rocket.core.model.ChatRoomRole
data class RoomViewModel(
val roles: List<ChatRoomRole>,
val isBroadcast: Boolean = false
val isBroadcast: Boolean = false,
val isRoom: Boolean = false
)
\ No newline at end of file
......@@ -120,7 +120,7 @@ class ViewModelMapper @Inject constructor(
private fun isBroadcastReplyAvailable(roomViewModel: RoomViewModel, message: Message): Boolean {
val senderUsername = message.sender?.username
return roomViewModel.isBroadcast &&
return roomViewModel.isRoom && roomViewModel.isBroadcast &&
!message.isSystemMessage() &&
senderUsername != currentUsername
}
......
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