Skip to content

Commit b029aec

Browse files
CopilotTlaster
andcommitted
Fix Windows cookie exception: use WryWebViewPanel directly instead of suspend cookie manager
Co-authored-by: Tlaster <8370277+Tlaster@users.noreply.github.com>
1 parent f8c07ca commit b029aec

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

desktopApp/src/main/kotlin/dev/dimension/flare/ui/screen/serviceselect/WebViewLoginScreen.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.runtime.LaunchedEffect
66
import androidx.compose.ui.Modifier
77
import io.github.kdroidfilter.webview.web.WebView
88
import io.github.kdroidfilter.webview.web.rememberWebViewState
9+
import io.github.kdroidfilter.webview.wry.WryWebViewPanel
910
import io.ktor.http.Url
1011
import kotlinx.coroutines.delay
1112
import kotlin.time.Duration.Companion.seconds
@@ -18,7 +19,7 @@ internal fun WebViewLoginScreen(
1819
) {
1920
val state = rememberWebViewState(url)
2021
LaunchedEffect(Unit) {
21-
state.cookieManager.removeAllCookies()
22+
(state.webView?.nativeWebView as? WryWebViewPanel)?.clearAllCookies()
2223
val urlData = Url(url)
2324
val actualUrl =
2425
urlData.protocol.name
@@ -27,7 +28,10 @@ internal fun WebViewLoginScreen(
2728
.plus("/")
2829
while (true) {
2930
delay(2.seconds)
30-
val cookies = state.cookieManager.getCookies(actualUrl)
31+
val cookies =
32+
(state.webView?.nativeWebView as? WryWebViewPanel)
33+
?.getCookiesForUrl(actualUrl)
34+
.orEmpty()
3135
if (callback.invoke(cookies.joinToString("; ") { "${it.name}=${it.value}" })) {
3236
onBack.invoke()
3337
break

0 commit comments

Comments
 (0)