fix: add Desktop OAuth timeout, restore iOS keyWindow filter

This commit is contained in:
2026-07-08 17:51:27 +02:00
parent 00e7a7456f
commit 5aa264c2a7
2 changed files with 8 additions and 2 deletions
@@ -1,6 +1,8 @@
package ch.parano.myice.auth
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.withTimeout
import java.awt.Desktop
import java.io.BufferedReader
import java.io.InputStreamReader
@@ -84,7 +86,11 @@ class DesktopOAuthClient : OAuthClient {
}
return try {
deferred.await()
withTimeout(5 * 60 * 1000L) {
deferred.await()
}
} catch (e: TimeoutCancellationException) {
null
} finally {
server.close()
}
@@ -66,7 +66,7 @@ class IosOAuthClient : OAuthClient {
private fun keyWindow(): UIWindow {
val scenes = UIApplication.sharedApplication.connectedScenes
val windowScene = scenes.firstOrNull { it is UIWindowScene } as? UIWindowScene
return (windowScene?.windows?.firstOrNull() as? UIWindow) ?: UIWindow()
return (windowScene?.windows?.firstOrNull { (it as? UIWindow)?.isKeyWindow() == true } as? UIWindow) ?: UIWindow()
}
companion object {