Commit 107e5f7c authored by Leonardo Aramaki's avatar Leonardo Aramaki

Hide chat menu items on broadcast channels when user has no post privileges

parent f41aa467
...@@ -148,6 +148,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -148,6 +148,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
private lateinit var actionSnackbar: ActionSnackbar private lateinit var actionSnackbar: ActionSnackbar
internal var citation: String? = null internal var citation: String? = null
private var editingMessageId: String? = null private var editingMessageId: String? = null
internal var disableMenu: Boolean = false
private val compositeDisposable = CompositeDisposable() private val compositeDisposable = CompositeDisposable()
private var playComposeMessageButtonsAnimation = true private var playComposeMessageButtonsAnimation = true
...@@ -355,7 +356,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -355,7 +356,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
ui { ui {
setupMessageComposer(userCanPost) setupMessageComposer(userCanPost)
isBroadcastChannel = channelIsBroadcast isBroadcastChannel = channelIsBroadcast
if (isBroadcastChannel && !userCanMod) activity?.invalidateOptionsMenu() if (isBroadcastChannel && !userCanMod) {
disableMenu = true
activity?.invalidateOptionsMenu()
}
} }
} }
......
...@@ -14,7 +14,21 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) { ...@@ -14,7 +14,21 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) {
setupSearchMessageMenuItem(menu, requireContext()) setupSearchMessageMenuItem(menu, requireContext())
setupFavoriteMenuItem(menu) setupFavoriteMenuItem(menu)
if (chatRoomType != RoomType.DIRECT_MESSAGE) { menu.add(
Menu.NONE,
MENU_ACTION_PINNED_MESSAGES,
Menu.NONE,
R.string.title_pinned_messages
)
menu.add(
Menu.NONE,
MENU_ACTION_FAVORITE_MESSAGES,
Menu.NONE,
R.string.title_favorite_messages
)
if (chatRoomType != RoomType.DIRECT_MESSAGE && !disableMenu) {
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_MEMBER, MENU_ACTION_MEMBER,
...@@ -30,26 +44,14 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) { ...@@ -30,26 +44,14 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) {
) )
} }
menu.add( if (!disableMenu) {
Menu.NONE, menu.add(
MENU_ACTION_PINNED_MESSAGES, Menu.NONE,
Menu.NONE, MENU_ACTION_FILES,
R.string.title_pinned_messages Menu.NONE,
) R.string.title_files
)
menu.add( }
Menu.NONE,
MENU_ACTION_FAVORITE_MESSAGES,
Menu.NONE,
R.string.title_favorite_messages
)
menu.add(
Menu.NONE,
MENU_ACTION_FILES,
Menu.NONE,
R.string.title_files
)
} }
internal fun ChatRoomFragment.setOnMenuItemClickListener(item: MenuItem) { internal fun ChatRoomFragment.setOnMenuItemClickListener(item: MenuItem) {
...@@ -101,7 +103,7 @@ private fun ChatRoomFragment.setupSearchViewTextListener(searchView: SearchView) ...@@ -101,7 +103,7 @@ private fun ChatRoomFragment.setupSearchViewTextListener(searchView: SearchView)
// TODO: We use isSearchTermQueried to avoid querying when the search view is expanded but the user doesn't start typing. Check for a native solution. // TODO: We use isSearchTermQueried to avoid querying when the search view is expanded but the user doesn't start typing. Check for a native solution.
if (it.isEmpty() && isSearchTermQueried) { if (it.isEmpty() && isSearchTermQueried) {
presenter.loadMessages(chatRoomId, chatRoomType, clearDataSet = true) presenter.loadMessages(chatRoomId, chatRoomType, clearDataSet = true)
} else if (it.isNotEmpty()){ } else if (it.isNotEmpty()) {
presenter.searchMessages(chatRoomId, it) presenter.searchMessages(chatRoomId, it)
isSearchTermQueried = true isSearchTermQueried = true
} }
......
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