fix: added 404 pages to history for better navigation 14ca5ce9
Steve · 2025-12-28 10:59 1 file(s) · +24 −0
Titan/Views/ContentView.swift +24 −0
286 286
        fetchContent(addToHistory: false)
287 287
    }
288 288
289 +
    private func addToNavigationHistory(url: String) {
290 +
        history.append(url)
291 +
        historyIndex = history.count - 1
292 +
        saveCurrentTabState()
293 +
    }
294 +
289 295
    private func fetchContent(addToHistory: Bool = true) {
290 296
        // Cancel any pending request before starting a new one
291 297
        currentFetchTask?.cancel()
341 347
                    showInputPrompt = true
342 348
                case .redirect:
343 349
                    currentError = .tooManyRedirects
350 +
                    if addToHistory {
351 +
                        addToNavigationHistory(url: finalURL)
352 +
                    }
344 353
                case .temporaryFailure:
345 354
                    currentError = .temporaryFailure(code: response.statusCode, meta: response.meta)
355 +
                    if addToHistory {
356 +
                        addToNavigationHistory(url: finalURL)
357 +
                    }
346 358
                case .permanentFailure:
347 359
                    currentError = .permanentFailure(code: response.statusCode, meta: response.meta)
360 +
                    if addToHistory {
361 +
                        addToNavigationHistory(url: finalURL)
362 +
                    }
348 363
                case .clientCertificate:
349 364
                    currentError = .clientCertificate(code: response.statusCode, meta: response.meta)
365 +
                    if addToHistory {
366 +
                        addToNavigationHistory(url: finalURL)
367 +
                    }
350 368
                }
351 369
                isLoading = false
352 370
            } catch is CancellationError {
364 382
                case .cancelled:
365 383
                    return
366 384
                }
385 +
                if addToHistory {
386 +
                    addToNavigationHistory(url: urlText)
387 +
                }
367 388
                isLoading = false
368 389
            } catch {
369 390
                currentError = .networkError(error.localizedDescription)
391 +
                if addToHistory {
392 +
                    addToNavigationHistory(url: urlText)
393 +
                }
370 394
                isLoading = false
371 395
            }
372 396
        }