Removing non necessary session id arg from ViewAction
This commit is contained in:
parent
e0c4706cf9
commit
cf6b8d76a8
|
@ -19,5 +19,5 @@ package im.vector.app.features.settings.devices.v2.overview
|
|||
import im.vector.app.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class SessionOverviewAction : VectorViewModelAction {
|
||||
data class VerifySession(val deviceId: String) : SessionOverviewAction()
|
||||
object VerifySession : SessionOverviewAction()
|
||||
}
|
||||
|
|
|
@ -62,8 +62,9 @@ class SessionOverviewFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initSessionInfoView()
|
||||
observeViewEvents()
|
||||
initSessionInfoView()
|
||||
initVerifyButton()
|
||||
}
|
||||
|
||||
private fun initSessionInfoView() {
|
||||
|
@ -72,6 +73,12 @@ class SessionOverviewFragment :
|
|||
}
|
||||
}
|
||||
|
||||
private fun initVerifyButton() {
|
||||
views.sessionOverviewInfo.viewVerifyButton.debouncedClicks {
|
||||
viewModel.handle(SessionOverviewAction.VerifySession)
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeViewEvents() {
|
||||
viewModel.observeViewEvents {
|
||||
when (it) {
|
||||
|
@ -96,7 +103,6 @@ class SessionOverviewFragment :
|
|||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
updateToolbar(state.isCurrentSession)
|
||||
updateVerifyButton(state.deviceId)
|
||||
updateEntryDetails(state.deviceId)
|
||||
if (state.deviceInfo is Success) {
|
||||
renderSessionInfo(state.isCurrentSession, state.deviceInfo.invoke())
|
||||
|
@ -112,12 +118,6 @@ class SessionOverviewFragment :
|
|||
?.setTitle(titleResId)
|
||||
}
|
||||
|
||||
private fun updateVerifyButton(deviceId: String) {
|
||||
views.sessionOverviewInfo.viewVerifyButton.debouncedClicks {
|
||||
viewModel.handle(SessionOverviewAction.VerifySession(deviceId))
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateEntryDetails(deviceId: String) {
|
||||
views.sessionOverviewEntryDetails.setOnClickListener {
|
||||
viewNavigator.navigateToSessionDetails(requireContext(), deviceId)
|
||||
|
|
|
@ -63,12 +63,12 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
|||
|
||||
override fun handle(action: SessionOverviewAction) {
|
||||
when (action) {
|
||||
is SessionOverviewAction.VerifySession -> handleVerifySessionAction(action)
|
||||
is SessionOverviewAction.VerifySession -> handleVerifySessionAction()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleVerifySessionAction(verifySession: SessionOverviewAction.VerifySession) {
|
||||
if (isCurrentSession(verifySession.deviceId)) {
|
||||
private fun handleVerifySessionAction() = withState { viewState ->
|
||||
if (isCurrentSession(viewState.deviceId)) {
|
||||
handleVerifyCurrentSession()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class SessionOverviewViewModelTest {
|
|||
val deviceFullInfo = mockk<DeviceFullInfo>()
|
||||
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
||||
every { isCurrentSessionUseCase.execute(any()) } returns true
|
||||
val verifySessionAction = SessionOverviewAction.VerifySession(A_SESSION_ID)
|
||||
val verifySessionAction = SessionOverviewAction.VerifySession
|
||||
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns true
|
||||
|
||||
// When
|
||||
|
@ -108,7 +108,7 @@ class SessionOverviewViewModelTest {
|
|||
val deviceFullInfo = mockk<DeviceFullInfo>()
|
||||
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
||||
every { isCurrentSessionUseCase.execute(any()) } returns true
|
||||
val verifySessionAction = SessionOverviewAction.VerifySession(A_SESSION_ID)
|
||||
val verifySessionAction = SessionOverviewAction.VerifySession
|
||||
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns false
|
||||
|
||||
// When
|
||||
|
|
Loading…
Reference in New Issue