Compare commits
2 Commits
71831e58f2
...
a8a8ea10a1
Author | SHA1 | Date |
---|---|---|
Shadowfacts | a8a8ea10a1 | |
Shadowfacts | d2f3ddf864 |
|
@ -68,7 +68,7 @@ public class NavigationManager: NSObject, ObservableObject {
|
|||
@objc public func reload() {
|
||||
let url = currentURL
|
||||
currentURL = url
|
||||
// todo: send navigation op
|
||||
navigationOperation.send(.reload)
|
||||
}
|
||||
|
||||
@objc public func goBack() {
|
||||
|
@ -105,6 +105,6 @@ public class NavigationManager: NSObject, ObservableObject {
|
|||
|
||||
public extension NavigationManager {
|
||||
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)
|
||||
newVC = BrowserWebViewController(navigator: navigator, url: navigator.currentURL)
|
||||
|
||||
case .reload:
|
||||
currentBrowserVC.reload()
|
||||
return
|
||||
|
||||
case let .backward(count: count):
|
||||
var removed = backBrowserVCs.suffix(count)
|
||||
backBrowserVCs.removeLast(count)
|
||||
|
|
|
@ -129,6 +129,11 @@ class BrowserWebViewController: UIViewController {
|
|||
loadDocument()
|
||||
}
|
||||
|
||||
func reload() {
|
||||
loaded = false
|
||||
loadDocument()
|
||||
}
|
||||
|
||||
private func loadDocument() {
|
||||
guard !loaded else { return }
|
||||
|
||||
|
@ -149,10 +154,11 @@ class BrowserWebViewController: UIViewController {
|
|||
}
|
||||
case let .success(response):
|
||||
if response.status.isRedirect {
|
||||
if let redirect = URL(string: response.meta) {
|
||||
self.navigator.changeURL(redirect)
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
DispatchQueue.main.async {
|
||||
print("Trying to redirect to: '\(response.meta)'")
|
||||
if let redirect = URL(string: response.meta) {
|
||||
self.navigator.changeURL(redirect)
|
||||
} else {
|
||||
self.showError(message: "Invalid redirect URL: '\(response.meta)'")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,11 +88,13 @@ class GeminiProtocol: NWProtocolFramerImplementation {
|
|||
let header = GeminiResponseHeader(status: statusCode, meta: meta)
|
||||
|
||||
let message = NWProtocolFramer.Message(geminiResponseHeader: header)
|
||||
while true {
|
||||
if !framer.deliverInputNoCopy(length: .max, message: message, isComplete: true) {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// What does the return value of deliverInputNoCopy mean, you ask? Why, I have no idea
|
||||
// It always returns true for a length of zero, so following the sample code and looping
|
||||
// infinitely until it returns false causes an infinite loop.
|
||||
// Additionally, calling deliverInput with an empty Data() causes an error inside Network.framework.
|
||||
// So, we just ignore the result since it doesn't seem to cause any problems ¯\_(ツ)_/¯
|
||||
_ = framer.deliverInputNoCopy(length: statusCode.isSuccess ? .max : 0, message: message, isComplete: true)
|
||||
return 0
|
||||
}
|
||||
|
||||
func handleOutput(framer: NWProtocolFramer.Instance, message: NWProtocolFramer.Message, messageLength: Int, isComplete: Bool) {
|
||||
|
|
Loading…
Reference in New Issue