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,42 +14,44 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) { ...@@ -14,42 +14,44 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) {
setupSearchMessageMenuItem(menu, requireContext()) setupSearchMessageMenuItem(menu, requireContext())
setupFavoriteMenuItem(menu) setupFavoriteMenuItem(menu)
if (chatRoomType != RoomType.DIRECT_MESSAGE) {
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_MEMBER, MENU_ACTION_PINNED_MESSAGES,
Menu.NONE, Menu.NONE,
R.string.title_members_list R.string.title_pinned_messages
) )
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_MENTIONS, MENU_ACTION_FAVORITE_MESSAGES,
Menu.NONE, Menu.NONE,
R.string.msg_mentions R.string.title_favorite_messages
) )
}
if (chatRoomType != RoomType.DIRECT_MESSAGE && !disableMenu) {
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_PINNED_MESSAGES, MENU_ACTION_MEMBER,
Menu.NONE, Menu.NONE,
R.string.title_pinned_messages R.string.title_members_list
) )
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_FAVORITE_MESSAGES, MENU_ACTION_MENTIONS,
Menu.NONE, Menu.NONE,
R.string.title_favorite_messages R.string.msg_mentions
) )
}
if (!disableMenu) {
menu.add( menu.add(
Menu.NONE, Menu.NONE,
MENU_ACTION_FILES, MENU_ACTION_FILES,
Menu.NONE, Menu.NONE,
R.string.title_files 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