Skip to content

Commit

Permalink
Merge pull request #6395 from vector-im/feature/bca/fix_invalid_qr_wa…
Browse files Browse the repository at this point in the history
…rning

Display specific message when verif code malformed
  • Loading branch information
BillCarsonFr authored Jul 21, 2022
2 parents 00c6ad5 + c0a2b39 commit fb05ab3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/6395.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display specific message when verification QR code is malformed
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal class DefaultQrCodeVerificationTransaction(
// Perform some checks
if (otherQrCodeData.transactionId != transactionId) {
Timber.d("## Verification QR: Invalid transaction actual ${otherQrCodeData.transactionId} expected:$transactionId")
cancel(CancelCode.QrCodeInvalid)
cancel(CancelCode.UnknownTransaction)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ class VerificationConclusionController @Inject constructor(

bottomGotIt()
}
ConclusionState.INVALID_QR_CODE -> {
bottomSheetVerificationNoticeItem {
id("invalid_qr")
notice(host.stringProvider.getString(R.string.verify_invalid_qr_notice).toEpoxyCharSequence())
}

bottomGotIt()
}
ConclusionState.CANCELLED -> {
bottomSheetVerificationNoticeItem {
id("notice_cancelled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ data class VerificationConclusionViewState(
enum class ConclusionState {
SUCCESS,
WARNING,
CANCELLED
CANCELLED,
INVALID_QR_CODE
}

class VerificationConclusionViewModel(initialState: VerificationConclusionViewState) :
Expand All @@ -44,7 +45,9 @@ class VerificationConclusionViewModel(initialState: VerificationConclusionViewSt
val args = viewModelContext.args<VerificationConclusionFragment.Args>()

return when (safeValueOf(args.cancelReason)) {
CancelCode.QrCodeInvalid,
CancelCode.QrCodeInvalid -> {
VerificationConclusionViewState(ConclusionState.INVALID_QR_CODE, args.isMe)
}
CancelCode.MismatchedUser,
CancelCode.MismatchedSas,
CancelCode.MismatchedCommitment,
Expand Down
1 change: 1 addition & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,7 @@
</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="recovery_passphrase">Recovery Passphrase</string>
Expand Down

0 comments on commit fb05ab3

Please sign in to comment.