MESSENGER-6018 layout changes simplified login and add error handling for timeouts

This commit is contained in:
JanNiklas Grabowski
2024-05-24 13:38:14 +02:00
parent df9741c530
commit 3475cdda0a
6 changed files with 41 additions and 5 deletions

View File

@@ -572,6 +572,8 @@
"authentication_qr_login_scan_title" = "Anmelden mit QR-Code";
"authentication_qr_login_start_title" = "Anmelden mit QR-Code";
"authentication_qr_login_start_button_title" = "QR-Code scannen";
"authentication_qr_login_failure_title" = "Verbindung fehlgeschlagen";
"authenticationQrLoginFailureRequestTimedOut" = "Die Verbindung konnte nicht in der erforderlichen Zeit hergestellt werden. Versuche es erneut.";
// MARK: - Login Protection
"bwi_login_protection_error_message" = "Der angegebene Server ist nicht für die Nutzung mit dem %@ vorgesehen";

View File

@@ -482,6 +482,8 @@
"authentication_qr_login_scan_title" = "Log in via QR code";
"authentication_qr_login_start_title" = "Log in via QR code";
"authentication_qr_login_start_button_title" = "Scan QR code";
"authentication_qr_login_failure_title" = "Unsuccessful connection";
"authenticationQrLoginFailureRequestTimedOut" = "Request failed in the required time. Please try again.";
// MARK: - Login Protection
"bwi_login_protection_error_message" = "The selected server is not allowed for using with %@";

View File

@@ -51,6 +51,10 @@ public class BWIL10n: NSObject {
public static var authenticationLoginUsername: String {
return BWIL10n.tr("Bwi", "authentication_login_username")
}
/// Verbindung fehlgeschlagen
public static var authenticationQrLoginFailureTitle: String {
return BWIL10n.tr("Bwi", "authentication_qr_login_failure_title")
}
/// Anmelden mit QR-Code
public static var authenticationQrLoginScanTitle: String {
return BWIL10n.tr("Bwi", "authentication_qr_login_scan_title")
@@ -99,6 +103,10 @@ public class BWIL10n: NSObject {
public static var authenticationServerSelectionSubmitButtonTitle: String {
return BWIL10n.tr("Bwi", "authentication_server_selection_submit_button_title")
}
/// Die Verbindung konnte nicht in der erforderlichen Zeit hergestellt werden. Versuche es erneut.
public static var authenticationQrLoginFailureRequestTimedOut: String {
return BWIL10n.tr("Bwi", "authenticationQrLoginFailureRequestTimedOut")
}
/// PIN eingeben
public static var biometricsModeCantUnlockButtonTitle: String {
return BWIL10n.tr("Bwi", "biometrics_mode_cant_unlock_button_title")

View File

@@ -240,13 +240,35 @@ class QRLoginService: NSObject, QRLoginServiceProtocol {
}
MXLog.debug("[QRLoginService] Waiting for the login token")
guard case let .success(data) = await rendezvousService.receive(),
// bwi: #6018 add error handling for request timeout and provide more information about the error to the user
let result = await rendezvousService.receive()
guard case let .success(data) = result,
let responsePayload = try? JSONDecoder().decode(QRLoginRendezvousPayload.self, from: data),
let login_token = responsePayload.loginToken,
let homeserver = responsePayload.homeserver,
let homeserverURL = URL(string: homeserver) else {
// Handle possible errors
MXLog.error("[QRLoginService] Invalid login details")
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
guard case let .failure(rendezvousError) = result else {
// Unkown error, display general error information
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
return
}
switch rendezvousError {
case .transportError(let transportError):
// Check for timeout
if transportError == .rendezvousCancelled {
await teardownRendezvous(state: .failed(error: .requestTimedOut))
} else {
// Display general error information for all other errors
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
}
break
default:
// Display general error information for all other errors
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
break
}
return
}
MXLog.debug("[QRLoginService] Received login token \(responsePayload)")

View File

@@ -62,7 +62,8 @@ class AuthenticationQRLoginFailureViewModel: AuthenticationQRLoginFailureViewMod
self.state.failureText = VectorL10n.authenticationQrLoginFailureRequestDenied
self.state.retryButtonVisible = false
case .requestTimedOut:
self.state.failureText = VectorL10n.authenticationQrLoginFailureRequestTimedOut
// bwi: #6018
self.state.failureText = BWIL10n.authenticationQrLoginFailureRequestTimedOut
self.state.retryButtonVisible = true
default:
break

View File

@@ -61,8 +61,9 @@ struct AuthenticationQRLoginFailureScreen: View {
}
.frame(width: iconSize, height: iconSize)
.padding(.bottom, 16)
Text(VectorL10n.authenticationQrLoginFailureTitle)
// bwi: #6018
Text(BWIL10n.authenticationQrLoginFailureTitle)
.font(theme.fonts.title3SB)
.multilineTextAlignment(.center)
.foregroundColor(theme.colors.primaryContent)