mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 20:38:40 +00:00
[LinkNewDevice] Move the timeout management when linking a new desktop device to the LinkNewDeviceFlowNode so that it can also be used for the DesktopNotice screen.
This commit is contained in:
committed by
Benoit Marty
parent
1a3b89de12
commit
aa6f70530a
+8
-3
@@ -53,15 +53,20 @@ class LinkNewDesktopHandler(
|
||||
timerJob = null
|
||||
}
|
||||
|
||||
fun createNewHandler() {
|
||||
resetJobs()
|
||||
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
||||
fun startTimer() {
|
||||
timerJob?.cancel()
|
||||
timerJob = sessionScope.launch {
|
||||
delay(2.minutes)
|
||||
linkDesktopStepFlow.emit(LinkDesktopStep.Error(ErrorType.Expired("Scanning QrCode took too long.")))
|
||||
}
|
||||
}
|
||||
|
||||
fun createNewHandler() {
|
||||
currentJob?.cancel()
|
||||
currentJob = null
|
||||
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
resetJobs()
|
||||
sessionScope.launch {
|
||||
|
||||
+8
@@ -263,6 +263,8 @@ class LinkNewDeviceFlowNode(
|
||||
}
|
||||
LinkDeviceType.Desktop -> {
|
||||
linkNewDesktopHandler.reset()
|
||||
// Ensure unlock state does not last longer than the timeout for scanning the QR code, so start the timer after unlock
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.push(NavTarget.DesktopNotice)
|
||||
}
|
||||
}
|
||||
@@ -278,10 +280,14 @@ class LinkNewDeviceFlowNode(
|
||||
NavTarget.DesktopNotice -> {
|
||||
val callback = object : DesktopNoticeNode.Callback {
|
||||
override fun navigateBack() {
|
||||
// reset the timer when the user leaves the screen (user will have to authenticate again)
|
||||
linkNewDesktopHandler.reset()
|
||||
backstack.pop()
|
||||
}
|
||||
|
||||
override fun navigateToQrCodeScanner() {
|
||||
// reset the timer when the user enters the next screen (they clicked on "Ready to scan")
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.push(NavTarget.DesktopScanQrCode)
|
||||
}
|
||||
}
|
||||
@@ -290,6 +296,8 @@ class LinkNewDeviceFlowNode(
|
||||
NavTarget.DesktopScanQrCode -> {
|
||||
val callback = object : ScanQrCodeNode.Callback {
|
||||
override fun cancel() {
|
||||
// reset the timer when the user goes back to the DesktopNoticeNode
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user