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
private lateinit var actionSnackbar: ActionSnackbar
internal var citation: String? = null
private var editingMessageId: String? = null
internal var disableMenu: Boolean = false
private val compositeDisposable = CompositeDisposable()
private var playComposeMessageButtonsAnimation = true
......@@ -355,7 +356,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
ui {
setupMessageComposer(userCanPost)
isBroadcastChannel = channelIsBroadcast
if (isBroadcastChannel && !userCanMod) activity?.invalidateOptionsMenu()
if (isBroadcastChannel && !userCanMod) {
disableMenu = true
activity?.invalidateOptionsMenu()
}
}
}
......
......@@ -14,42 +14,44 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) {
setupSearchMessageMenuItem(menu, requireContext())
setupFavoriteMenuItem(menu)
if (chatRoomType != RoomType.DIRECT_MESSAGE) {
menu.add(
Menu.NONE,
MENU_ACTION_MEMBER,
MENU_ACTION_PINNED_MESSAGES,
Menu.NONE,
R.string.title_members_list
R.string.title_pinned_messages
)
menu.add(
Menu.NONE,
MENU_ACTION_MENTIONS,
MENU_ACTION_FAVORITE_MESSAGES,
Menu.NONE,
R.string.msg_mentions
R.string.title_favorite_messages
)
}
if (chatRoomType != RoomType.DIRECT_MESSAGE && !disableMenu) {
menu.add(
Menu.NONE,
MENU_ACTION_PINNED_MESSAGES,
MENU_ACTION_MEMBER,
Menu.NONE,
R.string.title_pinned_messages
R.string.title_members_list
)
menu.add(
Menu.NONE,
MENU_ACTION_FAVORITE_MESSAGES,
MENU_ACTION_MENTIONS,
Menu.NONE,
R.string.title_favorite_messages
R.string.msg_mentions
)
}
if (!disableMenu) {
menu.add(
Menu.NONE,
MENU_ACTION_FILES,
Menu.NONE,
R.string.title_files
)
}
}
internal fun ChatRoomFragment.setOnMenuItemClickListener(item: MenuItem) {
......@@ -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.
if (it.isEmpty() && isSearchTermQueried) {
presenter.loadMessages(chatRoomId, chatRoomType, clearDataSet = true)
} else if (it.isNotEmpty()){
} else if (it.isNotEmpty()) {
presenter.searchMessages(chatRoomId, it)
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