Merge pull request #6395 from vector-im/feature/bca/fix_invalid_qr_warning

Display specific message when verif code malformed
This commit is contained in:
Valere 2022-07-21 12:36:46 +02:00 committed by GitHub
commit fb05ab34d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 3 deletions

1
changelog.d/6395.bugfix Normal file
View File

@ -0,0 +1 @@
Display specific message when verification QR code is malformed

View File

@ -84,7 +84,7 @@ internal class DefaultQrCodeVerificationTransaction(
// Perform some checks // Perform some checks
if (otherQrCodeData.transactionId != transactionId) { if (otherQrCodeData.transactionId != transactionId) {
Timber.d("## Verification QR: Invalid transaction actual ${otherQrCodeData.transactionId} expected:$transactionId") Timber.d("## Verification QR: Invalid transaction actual ${otherQrCodeData.transactionId} expected:$transactionId")
cancel(CancelCode.QrCodeInvalid) cancel(CancelCode.UnknownTransaction)
return return
} }

View File

@ -86,6 +86,14 @@ class VerificationConclusionController @Inject constructor(
bottomGotIt() bottomGotIt()
} }
ConclusionState.INVALID_QR_CODE -> {
bottomSheetVerificationNoticeItem {
id("invalid_qr")
notice(host.stringProvider.getString(R.string.verify_invalid_qr_notice).toEpoxyCharSequence())
}
bottomGotIt()
}
ConclusionState.CANCELLED -> { ConclusionState.CANCELLED -> {
bottomSheetVerificationNoticeItem { bottomSheetVerificationNoticeItem {
id("notice_cancelled") id("notice_cancelled")

View File

@ -32,7 +32,8 @@ data class VerificationConclusionViewState(
enum class ConclusionState { enum class ConclusionState {
SUCCESS, SUCCESS,
WARNING, WARNING,
CANCELLED CANCELLED,
INVALID_QR_CODE
} }
class VerificationConclusionViewModel(initialState: VerificationConclusionViewState) : class VerificationConclusionViewModel(initialState: VerificationConclusionViewState) :
@ -44,7 +45,9 @@ class VerificationConclusionViewModel(initialState: VerificationConclusionViewSt
val args = viewModelContext.args<VerificationConclusionFragment.Args>() val args = viewModelContext.args<VerificationConclusionFragment.Args>()
return when (safeValueOf(args.cancelReason)) { return when (safeValueOf(args.cancelReason)) {
CancelCode.QrCodeInvalid, CancelCode.QrCodeInvalid -> {
VerificationConclusionViewState(ConclusionState.INVALID_QR_CODE, args.isMe)
}
CancelCode.MismatchedUser, CancelCode.MismatchedUser,
CancelCode.MismatchedSas, CancelCode.MismatchedSas,
CancelCode.MismatchedCommitment, CancelCode.MismatchedCommitment,

View File

@ -2436,6 +2436,7 @@
</string> </string>
<string name="verify_cancelled_notice">Verification has been cancelled. You can start verification again.</string> <string name="verify_cancelled_notice">Verification has been cancelled. You can start verification again.</string>
<string name="verify_invalid_qr_notice">This QR code looks malformed. Please try to verify with another method.</string>
<string name="verification_cancelled">Verification Cancelled</string> <string name="verification_cancelled">Verification Cancelled</string>
<string name="recovery_passphrase">Recovery Passphrase</string> <string name="recovery_passphrase">Recovery Passphrase</string>