mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +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
|
timerJob = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createNewHandler() {
|
fun startTimer() {
|
||||||
resetJobs()
|
timerJob?.cancel()
|
||||||
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
|
||||||
timerJob = sessionScope.launch {
|
timerJob = sessionScope.launch {
|
||||||
delay(2.minutes)
|
delay(2.minutes)
|
||||||
linkDesktopStepFlow.emit(LinkDesktopStep.Error(ErrorType.Expired("Scanning QrCode took too long.")))
|
linkDesktopStepFlow.emit(LinkDesktopStep.Error(ErrorType.Expired("Scanning QrCode took too long.")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createNewHandler() {
|
||||||
|
currentJob?.cancel()
|
||||||
|
currentJob = null
|
||||||
|
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
resetJobs()
|
resetJobs()
|
||||||
sessionScope.launch {
|
sessionScope.launch {
|
||||||
|
|||||||
+8
@@ -263,6 +263,8 @@ class LinkNewDeviceFlowNode(
|
|||||||
}
|
}
|
||||||
LinkDeviceType.Desktop -> {
|
LinkDeviceType.Desktop -> {
|
||||||
linkNewDesktopHandler.reset()
|
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)
|
backstack.push(NavTarget.DesktopNotice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,10 +280,14 @@ class LinkNewDeviceFlowNode(
|
|||||||
NavTarget.DesktopNotice -> {
|
NavTarget.DesktopNotice -> {
|
||||||
val callback = object : DesktopNoticeNode.Callback {
|
val callback = object : DesktopNoticeNode.Callback {
|
||||||
override fun navigateBack() {
|
override fun navigateBack() {
|
||||||
|
// reset the timer when the user leaves the screen (user will have to authenticate again)
|
||||||
|
linkNewDesktopHandler.reset()
|
||||||
backstack.pop()
|
backstack.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun navigateToQrCodeScanner() {
|
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)
|
backstack.push(NavTarget.DesktopScanQrCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,6 +296,8 @@ class LinkNewDeviceFlowNode(
|
|||||||
NavTarget.DesktopScanQrCode -> {
|
NavTarget.DesktopScanQrCode -> {
|
||||||
val callback = object : ScanQrCodeNode.Callback {
|
val callback = object : ScanQrCodeNode.Callback {
|
||||||
override fun cancel() {
|
override fun cancel() {
|
||||||
|
// reset the timer when the user goes back to the DesktopNoticeNode
|
||||||
|
linkNewDesktopHandler.startTimer()
|
||||||
backstack.pop()
|
backstack.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user