Skip to content

Commit

Permalink
show option to accept other verif not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Jun 16, 2022
1 parent e5c45ee commit 111869d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,31 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
as? SasVerificationTransaction)
?.shortCodeDoesNotMatch()
}
is VerificationAction.ReadyPendingVerification -> {
withState { state ->
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 -> {
withState { state ->
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -131,5 +146,7 @@ class VerificationChooseMethodController @Inject constructor(
fun openCamera()
fun doVerifyBySas()
fun onClickOnWasNotMe()
fun acceptRequest()
fun declineRequest()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
}
}
Expand Down

0 comments on commit 111869d

Please sign in to comment.