Skip to content

Commit

Permalink
Fixes goBack() behavior (#2996)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414709148257752/1207663375808651/f

Description:

Fixes an issue caused by incomplete logic for the goBack() behavior when implementing DuckPlayer
Cleans up the goBack() method for clarity and early returns (remove if/else)
  • Loading branch information
afterxleep authored Jun 26, 2024
1 parent d460b80 commit 100cf9f
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -724,23 +724,30 @@ class TabViewController: UIViewController {
func goBack() {
dismissJSAlertIfNeeded()

if let handler = youtubeNavigationHandler {
if let url = url, url.isDuckPlayer, let handler = youtubeNavigationHandler {
handler.goBack(webView: webView)
chromeDelegate?.omniBar.resignFirstResponder()
} else {
if isError {
hideErrorMessage()
url = webView.url
onWebpageDidStartLoading(httpsForced: false)
onWebpageDidFinishLoading()
} else if webView.canGoBack {
webView.goBack()
chromeDelegate?.omniBar.resignFirstResponder()
} else if openingTab != nil {
delegate?.tabDidRequestClose(self)
}
return
}

if isError {
hideErrorMessage()
url = webView.url
onWebpageDidStartLoading(httpsForced: false)
onWebpageDidFinishLoading()
return
}

if webView.canGoBack {
webView.goBack()
chromeDelegate?.omniBar.resignFirstResponder()
return
}

if openingTab != nil {
delegate?.tabDidRequestClose(self)
}

}

func goForward() {
Expand Down

0 comments on commit 100cf9f

Please sign in to comment.