Compare commits

..

No commits in common. "a8a8ea10a143d5b061ac7489fc651ca2b344acce" and "71831e58f21d48bbfb540725542d6ea3dd53d2a3" have entirely different histories.

4 changed files with 11 additions and 23 deletions

View File

@ -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
navigationOperation.send(.reload) // todo: send navigation op
} }
@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, reload, forward(count: Int), backward(count: Int) case go, forward(count: Int), backward(count: Int)
} }
} }

View File

@ -134,10 +134,6 @@ 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)

View File

@ -129,11 +129,6 @@ class BrowserWebViewController: UIViewController {
loadDocument() loadDocument()
} }
func reload() {
loaded = false
loadDocument()
}
private func loadDocument() { private func loadDocument() {
guard !loaded else { return } guard !loaded else { return }
@ -154,11 +149,10 @@ class BrowserWebViewController: UIViewController {
} }
case let .success(response): case let .success(response):
if response.status.isRedirect { if response.status.isRedirect {
DispatchQueue.main.async { if let redirect = URL(string: response.meta) {
print("Trying to redirect to: '\(response.meta)'") self.navigator.changeURL(redirect)
if let redirect = URL(string: response.meta) { } else {
self.navigator.changeURL(redirect) DispatchQueue.main.async {
} else {
self.showError(message: "Invalid redirect URL: '\(response.meta)'") self.showError(message: "Invalid redirect URL: '\(response.meta)'")
} }
} }

View File

@ -88,13 +88,11 @@ class GeminiProtocol: NWProtocolFramerImplementation {
let header = GeminiResponseHeader(status: statusCode, meta: meta) let header = GeminiResponseHeader(status: statusCode, meta: meta)
let message = NWProtocolFramer.Message(geminiResponseHeader: header) let message = NWProtocolFramer.Message(geminiResponseHeader: header)
// What does the return value of deliverInputNoCopy mean, you ask? Why, I have no idea while true {
// It always returns true for a length of zero, so following the sample code and looping if !framer.deliverInputNoCopy(length: .max, message: message, isComplete: true) {
// infinitely until it returns false causes an infinite loop. return 0
// 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) { func handleOutput(framer: NWProtocolFramer.Instance, message: NWProtocolFramer.Message, messageLength: Int, isComplete: Bool) {