Skip to content

Commit

Permalink
fix(android): moved currentUrl assignment to onPageStarted (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed May 22, 2024
1 parent 637289d commit b6863ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/currentUrl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": patch
---

On Android, set `RustWebViewClient.currentUrl` field early in `onPageStarted` method instead of `onPageFinished`
2 changes: 1 addition & 1 deletion src/android/kotlin/RustWebViewClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RustWebViewClient(context: Context): WebViewClient() {
}

override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
currentUrl = url
if (interceptedState[url] == false) {
val webView = view as RustWebView
for (script in webView.initScripts) {
Expand All @@ -49,7 +50,6 @@ class RustWebViewClient(context: Context): WebViewClient() {
}

override fun onPageFinished(view: WebView, url: String) {
currentUrl = url
return onPageLoaded(url)
}

Expand Down

0 comments on commit b6863ed

Please sign in to comment.