Skip to content

Commit 65f6999

Browse files
authored
Merge pull request #1852 from DimensionDev/copilot/sub-pr-1851
Fix Windows cookie crash after composewebview alpha-13 bump
2 parents e84e87c + b029aec commit 65f6999

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.nativeWebView.getCookiesForUrl(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)