Commit a1963cc2 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Hide members list on broadcast channel

parent ff60cbf1
......@@ -15,7 +15,18 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.helper.UserHelper
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.infrastructure.username
import chat.rocket.android.server.domain.*
import chat.rocket.android.server.domain.GetChatRoomsInteractor
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.JobSchedulerInteractor
import chat.rocket.android.server.domain.MessagesRepository
import chat.rocket.android.server.domain.PermissionsInteractor
import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.server.domain.RoomRepository
import chat.rocket.android.server.domain.UsersRepository
import chat.rocket.android.server.domain.uploadMaxFileSize
import chat.rocket.android.server.domain.uploadMimeTypeFilter
import chat.rocket.android.server.domain.useRealName
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.server.infraestructure.state
import chat.rocket.android.util.extensions.avatarUrl
......@@ -29,7 +40,22 @@ import chat.rocket.common.model.roomTypeOf
import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.realtime.setTypingStatus
import chat.rocket.core.internal.realtime.socket.model.State
import chat.rocket.core.internal.rest.*
import chat.rocket.core.internal.rest.commands
import chat.rocket.core.internal.rest.deleteMessage
import chat.rocket.core.internal.rest.getMembers
import chat.rocket.core.internal.rest.history
import chat.rocket.core.internal.rest.joinChat
import chat.rocket.core.internal.rest.markAsRead
import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.messages
import chat.rocket.core.internal.rest.pinMessage
import chat.rocket.core.internal.rest.runCommand
import chat.rocket.core.internal.rest.sendMessage
import chat.rocket.core.internal.rest.spotlight
import chat.rocket.core.internal.rest.toggleReaction
import chat.rocket.core.internal.rest.unpinMessage
import chat.rocket.core.internal.rest.updateMessage
import chat.rocket.core.internal.rest.uploadFile
import chat.rocket.core.model.Command
import chat.rocket.core.model.Message
import chat.rocket.core.model.Myself
......@@ -73,10 +99,13 @@ class ChatRoomPresenter @Inject constructor(
private val stateChannel = Channel<State>()
private var lastState = manager.state
fun setupChatRoom() {
fun setupChatRoom(roomId: String) {
launchUI(strategy) {
val canPost = permissions.canPostToReadOnlyChannels()
view.onRoomChanged(canPost)
val broadcastChannel = getChatRoomsInteractor.getById(currentServer, roomId)?.run {
broadcast
} ?: false
view.onRoomUpdated(canPost, broadcastChannel)
}
}
......@@ -543,7 +572,7 @@ class ChatRoomPresenter @Inject constructor(
fun toMembersList(chatRoomId: String, chatRoomType: String) = navigator.toMembersList(chatRoomId, chatRoomType)
fun toPinnedMessageList(chatRoomId: String, chatRoomType: String) = navigator.toPinnedMessageList(chatRoomId,chatRoomType)
fun toPinnedMessageList(chatRoomId: String, chatRoomType: String) = navigator.toPinnedMessageList(chatRoomId, chatRoomType)
fun loadChatRooms() {
launchUI(strategy) {
......
......@@ -123,5 +123,8 @@ interface ChatRoomView : LoadingView, MessageView {
*/
fun populateCommandSuggestions(commands: List<CommandSuggestionViewModel>)
fun onRoomChanged(canPost: Boolean)
/**
* Communicate whether it's a broadcast channel and if current user can post to it.
*/
fun onRoomUpdated(canPost: Boolean, broadcastChannel: Boolean)
}
\ No newline at end of file
......@@ -113,6 +113,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private var isSubscribed: Boolean = true
private var isChatRoomReadOnly: Boolean = false
private var isChatRoomOwner: Boolean = false
private var isBroadcastChannel: Boolean = false
private lateinit var emojiKeyboardPopup: EmojiKeyboardPopup
private var chatRoomLastSeen: Long = -1
private lateinit var actionSnackbar: ActionSnackbar
......@@ -162,7 +163,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
super.onViewCreated(view, savedInstanceState)
setupToolbar(chatRoomName)
presenter.setupChatRoom()
presenter.setupChatRoom(chatRoomId)
presenter.loadMessages(chatRoomId, chatRoomType)
presenter.loadChatRooms()
setupRecyclerView()
......@@ -206,6 +207,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.chatroom_actions, menu)
menu.findItem(R.id.action_members_list)?.isVisible = !isBroadcastChannel
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
......@@ -265,8 +267,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override fun onRoomChanged(canPost: Boolean) {
override fun onRoomUpdated(canPost: Boolean, broadcastChannel: Boolean) {
setupMessageComposer(isChatRoomOwner || canPost)
isBroadcastChannel = broadcastChannel
if (isBroadcastChannel) activity?.invalidateOptionsMenu()
}
private fun toggleNoChatView(size: Int) {
......
......@@ -211,7 +211,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = null,
groupMentions = 0L,
lastMessage = null,
client = client
client = client,
broadcast = false
)
}
}
......@@ -244,7 +245,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = null,
groupMentions = 0L,
lastMessage = it.lastMessage,
client = client
client = client,
broadcast = it.broadcast
)
}
}
......@@ -335,7 +337,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = it.userMentions,
groupMentions = it.groupMentions,
lastMessage = it.lastMessage,
client = client
client = client,
broadcast = it.broadcast
)
chatRoomsList.add(newRoom)
}
......@@ -478,7 +481,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = userMentions,
groupMentions = groupMentions,
lastMessage = room.lastMessage,
client = client
client = client,
broadcast = broadcast
)
removeRoom(room.id, chatRooms)
chatRooms.add(newRoom)
......@@ -517,7 +521,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = subscription.userMentions,
groupMentions = subscription.groupMentions,
lastMessage = lastMessage,
client = client
client = client,
broadcast = broadcast
)
removeRoom(subscription.roomId, chatRooms)
chatRooms.add(newRoom)
......@@ -591,7 +596,8 @@ class ChatRoomsPresenter @Inject constructor(
userMentions = it.userMentions,
groupMentions = it.groupMentions,
lastMessage = it.lastMessage,
client = client
client = client,
broadcast = it.broadcast
)
getChatRoomsInteractor.remove(currentServer, it)
......
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