Confirm signout when it is current session
This commit is contained in:
parent
0fe5ee68f2
commit
68bee65e97
@ -40,6 +40,7 @@ import im.vector.app.databinding.FragmentSessionOverviewBinding
|
|||||||
import im.vector.app.features.auth.ReAuthActivity
|
import im.vector.app.features.auth.ReAuthActivity
|
||||||
import im.vector.app.features.crypto.recover.SetupMode
|
import im.vector.app.features.crypto.recover.SetupMode
|
||||||
import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState
|
import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState
|
||||||
|
import im.vector.app.features.workers.signout.SignOutUiWorker
|
||||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -86,12 +87,17 @@ class SessionOverviewFragment :
|
|||||||
navigator.open4SSetup(requireActivity(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
navigator.open4SSetup(requireActivity(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET)
|
||||||
}
|
}
|
||||||
is SessionOverviewViewEvent.RequestReAuth -> askForReAuthentication(it)
|
is SessionOverviewViewEvent.RequestReAuth -> askForReAuthentication(it)
|
||||||
|
SessionOverviewViewEvent.ConfirmSignoutCurrentSession -> confirmSignoutCurrentSession()
|
||||||
SessionOverviewViewEvent.SignoutSuccess -> viewNavigator.goBack(requireActivity())
|
SessionOverviewViewEvent.SignoutSuccess -> viewNavigator.goBack(requireActivity())
|
||||||
is SessionOverviewViewEvent.SignoutError -> showFailure(it.error)
|
is SessionOverviewViewEvent.SignoutError -> showFailure(it.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun confirmSignoutCurrentSession() {
|
||||||
|
activity?.let { SignOutUiWorker(it).perform() }
|
||||||
|
}
|
||||||
|
|
||||||
private fun initSessionInfoView() {
|
private fun initSessionInfoView() {
|
||||||
views.sessionOverviewInfo.onLearnMoreClickListener = {
|
views.sessionOverviewInfo.onLearnMoreClickListener = {
|
||||||
Toast.makeText(context, "Learn more verification status", Toast.LENGTH_LONG).show()
|
Toast.makeText(context, "Learn more verification status", Toast.LENGTH_LONG).show()
|
||||||
|
@ -28,6 +28,7 @@ sealed class SessionOverviewViewEvent : VectorViewEvents {
|
|||||||
val lastErrorCode: String?
|
val lastErrorCode: String?
|
||||||
) : SessionOverviewViewEvent()
|
) : SessionOverviewViewEvent()
|
||||||
|
|
||||||
|
object ConfirmSignoutCurrentSession : SessionOverviewViewEvent()
|
||||||
object SignoutSuccess : SessionOverviewViewEvent()
|
object SignoutSuccess : SessionOverviewViewEvent()
|
||||||
data class SignoutError(val error: Throwable) : SessionOverviewViewEvent()
|
data class SignoutError(val error: Throwable) : SessionOverviewViewEvent()
|
||||||
}
|
}
|
||||||
|
@ -130,10 +130,21 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
// TODO add unit tests
|
// TODO add unit tests
|
||||||
private fun handleSignoutSession() = withState { state ->
|
private fun handleSignoutSession() = withState { state ->
|
||||||
// TODO for current session: do the same process as sign out button in the general settings
|
if (state.deviceInfo.invoke()?.isCurrentDevice.orFalse()) {
|
||||||
|
handleSignoutCurrentSession()
|
||||||
|
} else {
|
||||||
|
handleSignoutOtherSession(state.deviceId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSignoutCurrentSession() {
|
||||||
|
_viewEvents.post(SessionOverviewViewEvent.ConfirmSignoutCurrentSession)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSignoutOtherSession(deviceId: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
val signoutResult = signout(state.deviceId)
|
val signoutResult = signout(deviceId)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|
||||||
if (signoutResult.isSuccess) {
|
if (signoutResult.isSuccess) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user