Link new device with QR code tweaks. (#5563)

* Hook up Rust's InvalidCheckCode failure to the right state when linking a new device.

* Automatically regenerate a new QR code instead of ending the flow when it expires.
This commit is contained in:
Doug
2026-05-11 14:22:34 +01:00
committed by GitHub
parent ded86dd66e
commit e235e3ba81
11 changed files with 106 additions and 31 deletions
@@ -111,6 +111,7 @@ enum QRCodeLoginError: Error, Equatable {
case providerNotAllowed(scannedProvider: String, allowedProviders: [String])
case cancelled
case connectionInsecure
case invalidCheckCode
case declined
case linkingNotSupported
case expired
@@ -195,8 +195,10 @@ extension LinkNewDeviceService.LinkDesktopProgress: CustomStringConvertible {
private extension QRCodeLoginError {
init(rustError: HumanQrGrantLoginError) {
self = switch rustError {
case .InvalidCheckCode, .ConnectionInsecure:
case .ConnectionInsecure:
.connectionInsecure
case .InvalidCheckCode:
.invalidCheckCode
case .UnsupportedProtocol:
.linkingNotSupported
case .Expired, .NotFound, .DeviceNotFound:
@@ -227,13 +229,6 @@ class CheckCodeSenderProxy: Equatable {
func send(code: UInt8) async throws {
try await underlyingSender.send(code: code)
}
/// Bypassed for now whilst we wait for an SDK update (however its worth noting that
/// things should still fail if the wrong code is provided, just not necessarily with
/// the right error being shown). https://github.com/matrix-org/matrix-rust-sdk/pull/5957
func validate(checkCode: UInt8) -> Bool {
true
}
}
extension UIImage {