mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +03:00
Merge pull request #7059 from vector-im/bugfix/eric/new-layout-open-invite
New Layout - Allows you to open an invite by clicking its cell
This commit is contained in:
commit
5dd26a43dd
4 changed files with 26 additions and 6 deletions
|
@ -20,6 +20,7 @@ import im.vector.app.core.platform.VectorViewModelAction
|
|||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
|
||||
sealed class InvitesAction : VectorViewModelAction {
|
||||
data class SelectRoom(val roomSummary: RoomSummary) : InvitesAction()
|
||||
data class AcceptInvitation(val roomSummary: RoomSummary) : InvitesAction()
|
||||
data class RejectInvitation(val roomSummary: RoomSummary) : InvitesAction()
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class InvitesFragment : VectorBaseFragment<FragmentInvitesBinding>(), RoomListLi
|
|||
viewModel.observeViewEvents {
|
||||
when (it) {
|
||||
is InvitesViewEvents.Failure -> showFailure(it.throwable)
|
||||
is InvitesViewEvents.OpenRoom -> handleOpenRoom(it.roomSummary, it.shouldCloseInviteView)
|
||||
is InvitesViewEvents.OpenRoom -> handleOpenRoom(it.roomSummary, it.shouldCloseInviteView, it.isInviteAlreadySelected)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,11 +94,15 @@ class InvitesFragment : VectorBaseFragment<FragmentInvitesBinding>(), RoomListLi
|
|||
}.launchIn(viewLifecycleOwner.lifecycleScope)
|
||||
}
|
||||
|
||||
private fun handleOpenRoom(roomSummary: RoomSummary, shouldCloseInviteView: Boolean) {
|
||||
private fun handleOpenRoom(
|
||||
roomSummary: RoomSummary,
|
||||
shouldCloseInviteView: Boolean,
|
||||
isInviteAlreadyAccepted: Boolean,
|
||||
) {
|
||||
navigator.openRoom(
|
||||
context = requireActivity(),
|
||||
roomId = roomSummary.roomId,
|
||||
isInviteAlreadyAccepted = true,
|
||||
isInviteAlreadyAccepted = isInviteAlreadyAccepted,
|
||||
trigger = ViewRoom.Trigger.RoomList // #6508
|
||||
)
|
||||
if (shouldCloseInviteView) {
|
||||
|
@ -120,7 +124,9 @@ class InvitesFragment : VectorBaseFragment<FragmentInvitesBinding>(), RoomListLi
|
|||
|
||||
override fun onSuggestedRoomClicked(room: SpaceChildInfo) = Unit
|
||||
|
||||
override fun onRoomClicked(room: RoomSummary) = Unit
|
||||
override fun onRoomClicked(room: RoomSummary) {
|
||||
viewModel.handle(InvitesAction.SelectRoom(room))
|
||||
}
|
||||
|
||||
override fun onRoomLongClicked(room: RoomSummary): Boolean = false
|
||||
}
|
||||
|
|
|
@ -21,5 +21,9 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
|||
|
||||
sealed class InvitesViewEvents : VectorViewEvents {
|
||||
data class Failure(val throwable: Throwable) : InvitesViewEvents()
|
||||
data class OpenRoom(val roomSummary: RoomSummary, val shouldCloseInviteView: Boolean) : InvitesViewEvents()
|
||||
data class OpenRoom(
|
||||
val roomSummary: RoomSummary,
|
||||
val shouldCloseInviteView: Boolean,
|
||||
val isInviteAlreadySelected: Boolean,
|
||||
) : InvitesViewEvents()
|
||||
}
|
||||
|
|
|
@ -76,11 +76,20 @@ class InvitesViewModel @AssistedInject constructor(
|
|||
|
||||
override fun handle(action: InvitesAction) {
|
||||
when (action) {
|
||||
is InvitesAction.SelectRoom -> handleSelectRoom(action)
|
||||
is InvitesAction.AcceptInvitation -> handleAcceptInvitation(action)
|
||||
is InvitesAction.RejectInvitation -> handleRejectInvitation(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSelectRoom(action: InvitesAction.SelectRoom) {
|
||||
_viewEvents.post(InvitesViewEvents.OpenRoom(
|
||||
roomSummary = action.roomSummary,
|
||||
shouldCloseInviteView = false,
|
||||
isInviteAlreadySelected = false,
|
||||
))
|
||||
}
|
||||
|
||||
private fun handleRejectInvitation(action: InvitesAction.RejectInvitation) = withState { state ->
|
||||
val roomId = action.roomSummary.roomId
|
||||
val roomMembershipChange = state.roomMembershipChanges[roomId]
|
||||
|
@ -129,7 +138,7 @@ class InvitesViewModel @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
_viewEvents.post(InvitesViewEvents.OpenRoom(action.roomSummary, shouldCloseInviteView))
|
||||
_viewEvents.post(InvitesViewEvents.OpenRoom(action.roomSummary, shouldCloseInviteView, isInviteAlreadySelected = true))
|
||||
}
|
||||
|
||||
private fun observeInvites() {
|
||||
|
|
Loading…
Reference in a new issue