Commit 4f175506 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Ignore being room creator for the room to check if one can post to the channel

parent 23174647
...@@ -123,9 +123,9 @@ interface ChatRoomView : LoadingView, MessageView { ...@@ -123,9 +123,9 @@ interface ChatRoomView : LoadingView, MessageView {
/** /**
* This user has joined the chat callback. * This user has joined the chat callback.
* *
* @param canPost Whether the user can post a message or not. * @param userCanPost Whether the user can post a message or not.
*/ */
fun onJoined(canPost: Boolean) fun onJoined(userCanPost: Boolean)
fun showReactionsPopup(messageId: String) fun showReactionsPopup(messageId: String)
......
...@@ -289,7 +289,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -289,7 +289,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override fun onRoomUpdated(userCanPost: Boolean, channelIsBroadcast: Boolean, userCanMod: Boolean) { override fun onRoomUpdated(userCanPost: Boolean, channelIsBroadcast: Boolean, userCanMod: Boolean) {
// TODO: We should rely solely on the user being able to post, but we cannot guarantee // TODO: We should rely solely on the user being able to post, but we cannot guarantee
// that the "(channels|groups).roles" endpoint is supported by the server in use. // that the "(channels|groups).roles" endpoint is supported by the server in use.
setupMessageComposer(userCanPost || isChatRoomCreator) setupMessageComposer(userCanPost)
isBroadcastChannel = channelIsBroadcast isBroadcastChannel = channelIsBroadcast
if (isBroadcastChannel && !userCanMod) activity?.invalidateOptionsMenu() if (isBroadcastChannel && !userCanMod) activity?.invalidateOptionsMenu()
} }
...@@ -628,7 +628,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -628,7 +628,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
input_container.setVisible(true) input_container.setVisible(true)
button_join_chat.setVisible(false) button_join_chat.setVisible(false)
isSubscribed = true isSubscribed = true
setupMessageComposer(userCanPost || isChatRoomCreator) setupMessageComposer(userCanPost)
} }
} }
...@@ -660,8 +660,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -660,8 +660,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
} }
private fun setupMessageComposer(canPost: Boolean) { private fun setupMessageComposer(canPost: Boolean) {
val showComposer = if (!canPost) canPost else isChatRoomCreator if (isChatRoomReadOnly && !canPost) {
if (!showComposer && isChatRoomReadOnly) {
text_room_is_read_only.setVisible(true) text_room_is_read_only.setVisible(true)
input_container.setVisible(false) input_container.setVisible(false)
} else if (!isSubscribed) { } else if (!isSubscribed) {
......
...@@ -48,7 +48,7 @@ class UserHelper @Inject constructor( ...@@ -48,7 +48,7 @@ class UserHelper @Inject constructor(
/** /**
* Return the username for the current logged [User]. * Return the username for the current logged [User].
*/ */
fun username(): String? = user()?.username fun username(): String? = localRepository.get(LocalRepository.CURRENT_USERNAME_KEY, null)
/** /**
* Whether current [User] is admin on the current server. * Whether current [User] is admin on the current server.
......
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