-
Notifications
You must be signed in to change notification settings - Fork 552
[NEW] Manage Users in a Room(Add/Remove) #2351
Conversation
I tried your implementation and I noticed a mistake.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this great pull request! 😃 Just a small change I would mention is to add all the newly added strings in all other strings resource files as well, so that it is more clear that they need to be translated and not to be forgotten, and remove TODO Translate
from the default file.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
Outdated
Show resolved
Hide resolved
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class ChatRoomRoleHelper @Inject constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not acting as a helper class. It is mostly a presenter...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipedelimabrito It helps in getting ChatRoles from chatroom id. It is used in PermissionsInterector. Should I move methods in PermissionsInterector? It will make PermissionsInterector long.
|
||
try { | ||
for (user in usersList) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using try { ...
again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipedelimabrito For each user it makes API call to server. And for each user we need to catch exception like user already added in the room
or something went wrong
Outer try block is used for hiding loading view and showing msg after API call is made for all the user in the list using finally block.
app/src/main/java/chat/rocket/android/inviteusers/ui/InviteUsersFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/chat/rocket/android/userdetails/presentation/UserDetailsPresenter.kt
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shailesh351 There are lots of issue here with the code indentation. Could you please make sure to follow our coding style?
app/src/main/java/chat/rocket/android/inviteusers/di/InviteUsersFragmentModule.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/chat/rocket/android/helper/ChatRoomRoleHelper.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/chat/rocket/android/helper/ChatRoomRoleHelper.kt
Outdated
Show resolved
Hide resolved
@filipedelimabrito Updated PR with RocketChat Coding Style. Till now I was using Tab instead of 4 Spaces. Sorry for that. |
roomTypeOf(getChatRoomType(chatRoomId)), | ||
user.userId | ||
) | ||
stringBuilder.append("Invited : ${user.username}\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded string. Please remove.
stringBuilder.append("Invited : ${user.username}\n") | ||
} catch (exception: RocketChatException) { | ||
exception.message?.let { | ||
stringBuilder.append("Exception : ${user.username} : $it\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded string. Please remove.
exception.message?.let { | ||
stringBuilder.append("Exception : ${user.username} : $it\n") | ||
}.ifNull { | ||
stringBuilder.append("Error : ${user.username} : Try again later\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded string. Please remove.
private const val BUNDLE_CHAT_ROOM_ID = "chat_room_id" | ||
|
||
class InviteUsersFragment : Fragment(), InviteUsersView { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded blank line.
|
||
/** | ||
* Loads all the chat room members for the given room id. | ||
* | ||
* @param roomId The id of the room to get chat room members from. | ||
*/ | ||
fun loadChatRoomsMembers(roomId: String) { | ||
fun loadChatRoomsMembers(roomId: String, offset: Long = 0, clearDataset: Boolean = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason of adding the offset param on the function declaration here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there is one bug in MembersFragment where members are not loaded as recycler view is scrolled using EndlessRecyclerViewListener. And only one page of member is shown.
To fix that I followed same pattern we are using for EndlessRecyclerView in ChatRoomFragment
https://github.com/RocketChat/Rocket.Chat.Android/blob/develop/app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt#L240
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fixed now - you can test by seeing a channel with a lot of users.
totalItemsCount: Int, | ||
recyclerView: RecyclerView | ||
) { | ||
presenter.loadChatRoomsMembers(chatRoomId, page * 60L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason of passing the offset here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same pattern as in ChatRoomFragement
https://github.com/RocketChat/Rocket.Chat.Android/blob/develop/app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt#L810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have simplified it (based on other classes we have too - e.g MentionsPresenter.kt
), but I see your point by choosing that approach. But since the offset is used on the presenter, moving it there can keep the scope...there. But I see your point.
<FrameLayout | ||
android:id="@+id/text_invite_users" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Widget isn't a text. So it shouldn't be get such id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending this PR @Shailesh351
- All requested changes here were addressed by my own. Pay attention to them for future reference if you want. Thanks ❤️
@RocketChat/android
Closes #1230
Changes:
Screenshots or GIF for the change: