show option to accept other verif not ready

This commit is contained in:
Valere 2022-06-16 16:44:30 +02:00
parent 622ada7125
commit 142c87314c
5 changed files with 56 additions and 2 deletions

View File

@ -30,6 +30,8 @@ sealed class VerificationAction : VectorViewModelAction {
data class GotItConclusion(val verified: Boolean) : VerificationAction()
object SkipVerification : VerificationAction()
object VerifyFromPassphrase : VerificationAction()
object ReadyPendingVerification : VerificationAction()
object CancelPendingVerification : VerificationAction()
data class GotResultFromSsss(val cypherData: String, val alias: String) : VerificationAction()
object CancelledFromSsss : VerificationAction()
object SecuredStorageHasBeenReset : VerificationAction()

View File

@ -360,6 +360,27 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
as? SasVerificationTransaction)
?.shortCodeDoesNotMatch()
}
is VerificationAction.ReadyPendingVerification -> {
state.pendingRequest.invoke()?.let { request ->
// will only be there for dm verif
if (state.roomId != null) {
session.cryptoService().verificationService()
.readyPendingVerificationInDMs(
supportedVerificationMethodsProvider.provide(),
state.otherUserId,
state.roomId,
request.transactionId ?: ""
)
}
}
}
is VerificationAction.CancelPendingVerification -> {
state.pendingRequest.invoke()?.let {
session.cryptoService().verificationService()
.cancelVerificationRequest(it)
}
_viewEvents.post(VerificationBottomSheetViewEvents.Dismiss)
}
is VerificationAction.GotItConclusion -> {
if (state.isVerificationRequired && !action.verified) {
// we should go back to first screen

View File

@ -21,6 +21,7 @@ import im.vector.app.R
import im.vector.app.core.epoxy.bottomSheetDividerItem
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.genericButtonItem
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationQrCodeItem
@ -108,6 +109,20 @@ class VerificationChooseMethodController @Inject constructor(
iconColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
listener { host.listener?.doVerifyBySas() }
}
} else if (!state.isReadied) {
// a bit of a special case, if you tapped on the timeline cell but not on a button
genericButtonItem {
id("accept_request")
textColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
text(host.stringProvider.getString(R.string.action_accept))
buttonClickAction { host.listener?.acceptRequest() }
}
genericButtonItem {
id("decline_request")
textColor(host.colorProvider.getColorFromAttribute(R.attr.colorError))
text(host.stringProvider.getString(R.string.action_decline))
buttonClickAction { host.listener?.declineRequest() }
}
}
if (state.isMe && state.canCrossSign) {
@ -131,5 +146,7 @@ class VerificationChooseMethodController @Inject constructor(
fun openCamera()
fun doVerifyBySas()
fun onClickOnWasNotMe()
fun acceptRequest()
fun declineRequest()
}
}

View File

@ -100,6 +100,18 @@ class VerificationChooseMethodFragment @Inject constructor(
sharedViewModel.itWasNotMe()
}
override fun acceptRequest() {
withState(viewModel) {
sharedViewModel.handle(VerificationAction.ReadyPendingVerification)
}
}
override fun declineRequest() {
withState(viewModel) {
sharedViewModel.handle(VerificationAction.CancelPendingVerification)
}
}
private fun doOpenQRCodeScanner() {
QrCodeScannerActivity.startForResult(requireActivity(), scanActivityResultLauncher)
}

View File

@ -44,7 +44,8 @@ data class VerificationChooseMethodViewState(
val qrCodeText: String? = null,
val sasModeAvailable: Boolean = false,
val isMe: Boolean = false,
val canCrossSign: Boolean = false
val canCrossSign: Boolean = false,
val isReadied: Boolean = false
) : MavericksState
class VerificationChooseMethodViewModel @AssistedInject constructor(
@ -81,7 +82,8 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
copy(
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
sasModeAvailable = pvr?.isSasSupported().orFalse()
sasModeAvailable = pvr?.isSasSupported().orFalse(),
isReadied = pvr?.isReady ?: false,
)
}
}