Fix reload not working
This commit is contained in:
parent
71831e58f2
commit
d2f3ddf864
|
@ -68,7 +68,7 @@ public class NavigationManager: NSObject, ObservableObject {
|
||||||
@objc public func reload() {
|
@objc public func reload() {
|
||||||
let url = currentURL
|
let url = currentURL
|
||||||
currentURL = url
|
currentURL = url
|
||||||
// todo: send navigation op
|
navigationOperation.send(.reload)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func goBack() {
|
@objc public func goBack() {
|
||||||
|
@ -105,6 +105,6 @@ public class NavigationManager: NSObject, ObservableObject {
|
||||||
|
|
||||||
public extension NavigationManager {
|
public extension NavigationManager {
|
||||||
enum Operation {
|
enum Operation {
|
||||||
case go, forward(count: Int), backward(count: Int)
|
case go, reload, forward(count: Int), backward(count: Int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,10 @@ class BrowserNavigationController: UIViewController {
|
||||||
backBrowserVCs.append(currentBrowserVC)
|
backBrowserVCs.append(currentBrowserVC)
|
||||||
newVC = BrowserWebViewController(navigator: navigator, url: navigator.currentURL)
|
newVC = BrowserWebViewController(navigator: navigator, url: navigator.currentURL)
|
||||||
|
|
||||||
|
case .reload:
|
||||||
|
currentBrowserVC.reload()
|
||||||
|
return
|
||||||
|
|
||||||
case let .backward(count: count):
|
case let .backward(count: count):
|
||||||
var removed = backBrowserVCs.suffix(count)
|
var removed = backBrowserVCs.suffix(count)
|
||||||
backBrowserVCs.removeLast(count)
|
backBrowserVCs.removeLast(count)
|
||||||
|
|
|
@ -129,6 +129,11 @@ class BrowserWebViewController: UIViewController {
|
||||||
loadDocument()
|
loadDocument()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reload() {
|
||||||
|
loaded = false
|
||||||
|
loadDocument()
|
||||||
|
}
|
||||||
|
|
||||||
private func loadDocument() {
|
private func loadDocument() {
|
||||||
guard !loaded else { return }
|
guard !loaded else { return }
|
||||||
|
|
||||||
|
@ -149,6 +154,7 @@ class BrowserWebViewController: UIViewController {
|
||||||
}
|
}
|
||||||
case let .success(response):
|
case let .success(response):
|
||||||
if response.status.isRedirect {
|
if response.status.isRedirect {
|
||||||
|
print("Trying to redirect to: '\(response.meta)'")
|
||||||
if let redirect = URL(string: response.meta) {
|
if let redirect = URL(string: response.meta) {
|
||||||
self.navigator.changeURL(redirect)
|
self.navigator.changeURL(redirect)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue