From 5aa264c2a74df9a0800549c3a2f81ccb762bd646 Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Wed, 8 Jul 2026 17:51:27 +0200 Subject: [PATCH] fix: add Desktop OAuth timeout, restore iOS keyWindow filter --- .../kotlin/ch/parano/myice/auth/DesktopOAuthClient.kt | 8 +++++++- .../iosMain/kotlin/ch/parano/myice/auth/IosOAuthClient.kt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/composeApp/src/desktopMain/kotlin/ch/parano/myice/auth/DesktopOAuthClient.kt b/composeApp/src/desktopMain/kotlin/ch/parano/myice/auth/DesktopOAuthClient.kt index 3bacdba..6c97725 100644 --- a/composeApp/src/desktopMain/kotlin/ch/parano/myice/auth/DesktopOAuthClient.kt +++ b/composeApp/src/desktopMain/kotlin/ch/parano/myice/auth/DesktopOAuthClient.kt @@ -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() } diff --git a/composeApp/src/iosMain/kotlin/ch/parano/myice/auth/IosOAuthClient.kt b/composeApp/src/iosMain/kotlin/ch/parano/myice/auth/IosOAuthClient.kt index 8adfcb0..30ddfd9 100644 --- a/composeApp/src/iosMain/kotlin/ch/parano/myice/auth/IosOAuthClient.kt +++ b/composeApp/src/iosMain/kotlin/ch/parano/myice/auth/IosOAuthClient.kt @@ -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 {