diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt index 776138a686..a3ffd80ade 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt @@ -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, diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt index f2c85c96c7..78562ea351 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -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() diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewState.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewState.kt index dec003b37d..f943a5cf08 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewState.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewState.kt @@ -39,6 +39,7 @@ data class RoomMemberProfileViewState( val allDevicesAreTrusted: Boolean = false, val allDevicesAreCrossSignedTrusted: Boolean = false, val asyncMembership: Async = Uninitialized, + val hasReadReceipt: Boolean = false, val actionPermissions: ActionPermissions = ActionPermissions() ) : MvRxState { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt index 6bcb9f9c7f..734620e378 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt @@ -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() diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt index d6d56b8cb9..67577e866e 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt @@ -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()