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
|
import im.vector.app.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
sealed class SessionOverviewAction : 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?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initSessionInfoView()
|
|
||||||
observeViewEvents()
|
observeViewEvents()
|
||||||
|
initSessionInfoView()
|
||||||
|
initVerifyButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initSessionInfoView() {
|
private fun initSessionInfoView() {
|
||||||
|
@ -72,6 +73,12 @@ class SessionOverviewFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initVerifyButton() {
|
||||||
|
views.sessionOverviewInfo.viewVerifyButton.debouncedClicks {
|
||||||
|
viewModel.handle(SessionOverviewAction.VerifySession)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun observeViewEvents() {
|
private fun observeViewEvents() {
|
||||||
viewModel.observeViewEvents {
|
viewModel.observeViewEvents {
|
||||||
when (it) {
|
when (it) {
|
||||||
|
@ -96,7 +103,6 @@ class SessionOverviewFragment :
|
||||||
|
|
||||||
override fun invalidate() = withState(viewModel) { state ->
|
override fun invalidate() = withState(viewModel) { state ->
|
||||||
updateToolbar(state.isCurrentSession)
|
updateToolbar(state.isCurrentSession)
|
||||||
updateVerifyButton(state.deviceId)
|
|
||||||
updateEntryDetails(state.deviceId)
|
updateEntryDetails(state.deviceId)
|
||||||
if (state.deviceInfo is Success) {
|
if (state.deviceInfo is Success) {
|
||||||
renderSessionInfo(state.isCurrentSession, state.deviceInfo.invoke())
|
renderSessionInfo(state.isCurrentSession, state.deviceInfo.invoke())
|
||||||
|
@ -112,12 +118,6 @@ class SessionOverviewFragment :
|
||||||
?.setTitle(titleResId)
|
?.setTitle(titleResId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateVerifyButton(deviceId: String) {
|
|
||||||
views.sessionOverviewInfo.viewVerifyButton.debouncedClicks {
|
|
||||||
viewModel.handle(SessionOverviewAction.VerifySession(deviceId))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateEntryDetails(deviceId: String) {
|
private fun updateEntryDetails(deviceId: String) {
|
||||||
views.sessionOverviewEntryDetails.setOnClickListener {
|
views.sessionOverviewEntryDetails.setOnClickListener {
|
||||||
viewNavigator.navigateToSessionDetails(requireContext(), deviceId)
|
viewNavigator.navigateToSessionDetails(requireContext(), deviceId)
|
||||||
|
|
|
@ -63,12 +63,12 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
override fun handle(action: SessionOverviewAction) {
|
override fun handle(action: SessionOverviewAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is SessionOverviewAction.VerifySession -> handleVerifySessionAction(action)
|
is SessionOverviewAction.VerifySession -> handleVerifySessionAction()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleVerifySessionAction(verifySession: SessionOverviewAction.VerifySession) {
|
private fun handleVerifySessionAction() = withState { viewState ->
|
||||||
if (isCurrentSession(verifySession.deviceId)) {
|
if (isCurrentSession(viewState.deviceId)) {
|
||||||
handleVerifyCurrentSession()
|
handleVerifyCurrentSession()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class SessionOverviewViewModelTest {
|
||||||
val deviceFullInfo = mockk<DeviceFullInfo>()
|
val deviceFullInfo = mockk<DeviceFullInfo>()
|
||||||
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
||||||
every { isCurrentSessionUseCase.execute(any()) } returns true
|
every { isCurrentSessionUseCase.execute(any()) } returns true
|
||||||
val verifySessionAction = SessionOverviewAction.VerifySession(A_SESSION_ID)
|
val verifySessionAction = SessionOverviewAction.VerifySession
|
||||||
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns true
|
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns true
|
||||||
|
|
||||||
// When
|
// When
|
||||||
|
@ -108,7 +108,7 @@ class SessionOverviewViewModelTest {
|
||||||
val deviceFullInfo = mockk<DeviceFullInfo>()
|
val deviceFullInfo = mockk<DeviceFullInfo>()
|
||||||
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo)
|
||||||
every { isCurrentSessionUseCase.execute(any()) } returns true
|
every { isCurrentSessionUseCase.execute(any()) } returns true
|
||||||
val verifySessionAction = SessionOverviewAction.VerifySession(A_SESSION_ID)
|
val verifySessionAction = SessionOverviewAction.VerifySession
|
||||||
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns false
|
coEvery { checkIfCurrentSessionCanBeVerifiedUseCase.execute() } returns false
|
||||||
|
|
||||||
// When
|
// When
|
||||||
|
|
Loading…
Reference in New Issue