mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Improve detection of link device completion when linking a new device via QR (#5323)
* Improve detection of link device completion * Fix tests to match
This commit is contained in:
@@ -224,12 +224,10 @@ class QRCodeLoginScreenViewModel: QRCodeLoginScreenViewModelType, QRCodeLoginScr
|
||||
case .waitingForAuthorisation(let url):
|
||||
requestOIDCAuthorization(url: url)
|
||||
case .syncingSecrets:
|
||||
// break // Nothing to do.
|
||||
// .done is rarely received at the moment, so lets consider linking to be done here.
|
||||
break // Nothing to do.
|
||||
case .done:
|
||||
MXLog.info("Link with QR code completed.")
|
||||
actionsSubject.send(.linkedDevice)
|
||||
case .done:
|
||||
break // Not necessary right now with the workaround above in place.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ class LinkNewDeviceService: LinkNewDeviceServiceProtocol {
|
||||
do {
|
||||
// Note: The SDK doesn't provide us with a way to cancel the grant if the user hit the cancel button 🤷♂️
|
||||
try await grantLoginHandler.generate(progressListener: listener) // The success state is handled by the listener.
|
||||
// We send the .done progress in case the listener didn't get a chance to pass it on from the SDK before being deallocated
|
||||
progressSubject.send(LinkMobileProgress.done)
|
||||
} catch let error as HumanQrGrantLoginError {
|
||||
MXLog.error("QR code reciprocate error: \(error)")
|
||||
progressSubject.send(completion: .failure(.init(rustError: error)))
|
||||
@@ -105,6 +107,8 @@ class LinkNewDeviceService: LinkNewDeviceServiceProtocol {
|
||||
do {
|
||||
// Note: The SDK doesn't provide us with a way to cancel the grant if the user hit the cancel button 🤷♂️
|
||||
try await grantLoginHandler.scan(qrCodeData: qrCodeData, progressListener: listener) // The success state is handled by the listener.
|
||||
// We send the .done progress in case the listener didn't get a chance to pass it on from the SDK before being deallocated
|
||||
progressSubject.send(LinkDesktopProgress.done)
|
||||
} catch let error as HumanQrGrantLoginError {
|
||||
MXLog.error("QR code reciprocate error: \(error)")
|
||||
progressSubject.send(completion: .failure(.init(rustError: error)))
|
||||
|
||||
Reference in New Issue
Block a user