Correction: "Jump to read receipt" available only for members with read receipt info (invited member can have read receipt info from a previous membership)

Not live for the moment, I think it is acceptable.
Also the Activity will finish itself instead of the Fragment
This commit is contained in:
Benoit Marty 2020-10-06 10:05:20 +02:00 committed by Benoit Marty
parent 6325ee9310
commit e33bc7146b
5 changed files with 16 additions and 12 deletions

View File

@ -173,7 +173,7 @@ class RoomMemberProfileController @Inject constructor(
buildProfileSection(stringProvider.getString(R.string.room_profile_section_more))
if (membership == Membership.JOIN) {
if (state.hasReadReceipt) {
buildProfileAction(
id = "read_receipt",
editable = false,

View File

@ -85,7 +85,8 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
setState {
copy(
isMine = session.myUserId == this.userId,
userMatrixItem = room?.getRoomMember(initialState.userId)?.toMatrixItem()?.let { Success(it) } ?: Uninitialized
userMatrixItem = room?.getRoomMember(initialState.userId)?.toMatrixItem()?.let { Success(it) } ?: Uninitialized,
hasReadReceipt = room?.getUserReadReceipt(initialState.userId) != null
)
}
observeIgnoredState()

View File

@ -39,6 +39,7 @@ data class RoomMemberProfileViewState(
val allDevicesAreTrusted: Boolean = false,
val allDevicesAreCrossSignedTrusted: Boolean = false,
val asyncMembership: Async<Membership> = Uninitialized,
val hasReadReceipt: Boolean = false,
val actionPermissions: ActionPermissions = ActionPermissions()
) : MvRxState {

View File

@ -29,6 +29,7 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.addFragmentToBackstack
import im.vector.app.core.platform.ToolbarConfigurable
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
import im.vector.app.features.room.RequireActiveMembershipViewEvents
import im.vector.app.features.room.RequireActiveMembershipViewModel
import im.vector.app.features.room.RequireActiveMembershipViewState
@ -61,6 +62,9 @@ class RoomProfileActivity :
@Inject
lateinit var requireActiveMembershipViewModelFactory: RequireActiveMembershipViewModel.Factory
@Inject
lateinit var roomDetailPendingActionStore: RoomDetailPendingActionStore
override fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel {
return requireActiveMembershipViewModelFactory.create(initialState)
}
@ -97,6 +101,13 @@ class RoomProfileActivity :
}
}
override fun onResume() {
super.onResume()
if (roomDetailPendingActionStore.data != null) {
finish()
}
}
private fun handleRoomLeft(roomLeft: RequireActiveMembershipViewEvents.RoomLeft) {
if (roomLeft.leftMessage != null) {
Toast.makeText(this, roomLeft.leftMessage, Toast.LENGTH_LONG).show()

View File

@ -36,7 +36,6 @@ import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
import im.vector.app.features.roomprofile.RoomProfileArgs
import kotlinx.android.synthetic.main.fragment_room_setting_generic.*
import javax.inject.Inject
@ -44,8 +43,7 @@ import javax.inject.Inject
class RoomMemberListFragment @Inject constructor(
val viewModelFactory: RoomMemberListViewModel.Factory,
private val roomMemberListController: RoomMemberListController,
private val avatarRenderer: AvatarRenderer,
private val roomDetailPendingActionStore: RoomDetailPendingActionStore
private val avatarRenderer: AvatarRenderer
) : VectorBaseFragment(), RoomMemberListController.Callback {
private val viewModel: RoomMemberListViewModel by fragmentViewModel()
@ -98,13 +96,6 @@ class RoomMemberListFragment @Inject constructor(
})
}
override fun onResume() {
super.onResume()
if (roomDetailPendingActionStore.data != null) {
vectorBaseActivity.finish()
}
}
override fun onDestroyView() {
recyclerView.cleanup()
super.onDestroyView()