Skip to content

Commit

Permalink
fix: Handle redirection within Discovery WebViews
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaIsrar12 committed Jul 22, 2024
1 parent ccfce12 commit 3b44f31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fun CatalogWebViewScreen(
refreshSessionCookie = refreshSessionCookie,
) {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
url?.let { onWebPageUpdated(it) }
super.onPageFinished(view, url)
}

override fun onPageCommitVisible(view: WebView?, url: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ open class DefaultWebViewClient(
) : WebViewClient() {

private var hostForThisPage: String? = null
private var isPossibleRedirection = true

override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
Expand All @@ -31,7 +32,7 @@ open class DefaultWebViewClient(
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val clickUrl = request?.url?.toString() ?: ""

if (clickUrl.isNotEmpty() && (isAllLinksExternal || isExternalLink(clickUrl))) {
if (clickUrl.isNotEmpty() && (isAllLinksExternal || isExternalLink(clickUrl)) && !isPossibleRedirection) {
onUriClick(clickUrl, WebViewLink.Authority.EXTERNAL)
return true
}
Expand All @@ -49,6 +50,11 @@ open class DefaultWebViewClient(
}
}

override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
isPossibleRedirection = false
}

override fun onReceivedHttpError(
view: WebView,
request: WebResourceRequest,
Expand Down

0 comments on commit 3b44f31

Please sign in to comment.