fix: add Desktop OAuth timeout, restore iOS keyWindow filter
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user