[Link new device] Automatically rotate the QR Code

This commit is contained in:
Benoit Marty 2026-05-19 09:00:11 +02:00 committed by Benoit Marty
parent 7571289347
commit 4e535a8a16
9 changed files with 152 additions and 12 deletions

View file

@ -18,6 +18,7 @@ sealed interface LinkMobileStep {
data object Uninitialized : LinkMobileStep
data object Starting : LinkMobileStep
data class QrReady(val data: String) : LinkMobileStep
data object QrRotating : LinkMobileStep
data class WaitingForAuth(val verificationUri: String) : LinkMobileStep
data class QrScanned(val checkCodeSender: CheckCodeSender) : LinkMobileStep
data class Error(val errorType: ErrorType) : LinkMobileStep

View file

@ -53,7 +53,14 @@ class RustLinkMobileHandler(
_linkMobileStep.emit(LinkMobileStep.Done)
} catch (e: HumanQrGrantLoginException) {
Timber.tag(tag.value).w(e, "Error during QR login grant")
_linkMobileStep.emit(LinkMobileStep.Error(e.map()))
// Catch timeout here?
if (_linkMobileStep.value is LinkMobileStep.QrReady
&& e is HumanQrGrantLoginException.NotFound) {
Timber.tag(tag.value).d("Emit QrRotating due to HumanQrGrantLoginException.NotFound")
_linkMobileStep.emit(LinkMobileStep.QrRotating)
} else {
_linkMobileStep.emit(LinkMobileStep.Error(e.map()))
}
}
}