Skip to content

fix(#281): preserve article reading position when returning from links#310

Merged
cassio-rossi merged 2 commits into
release/v5from
fix/webview-reading-position
Jul 18, 2026
Merged

fix(#281): preserve article reading position when returning from links#310
cassio-rossi merged 2 commits into
release/v5from
fix/webview-reading-position

Conversation

@cassio-rossi

Copy link
Copy Markdown
Collaborator

Summary

Fixes #281 — tapping any link inside an article (external Safari or the inline pushed browser) reloaded the article and lost the reading position on return.

Root causes

  1. Inline browser (push/pop): ManagedWebView's .task(id: reloadTrigger) restarts when the covered article reappears and unconditionally re-ran performLoad — a full URL load for articles, since they pass no cacheKey.
  2. External Safari: while backgrounding, iOS renders app-switcher snapshots in both appearances, firing colorScheme onChange twice — each flip triggered page?.reload() in MMWebView plus a cookie-update + full reload in ManagedWebView.

Changes

  • WebViewLoadPolicy (new): pure decision logic — skip a load whose trigger already completed; ignore color-scheme changes while the scene is not active; reconcile only when the appearance genuinely changed while away.
  • ManagedWebView: tracks completedLoadTrigger (skips the redundant pop-back reload; cleared on .webContentProcessTerminated so a jettisoned page recovers) and appliedColorScheme (snapshot flips ignored; a real appearance change is applied once on return to .active).
  • MMWebView: same scenePhase gating + reconciliation around page?.reload().
  • The isActive scenePhase crash-prevention gating and the removeAds reload path are untouched.

Quality gates

  • ✅ Build succeeded (iOS Simulator)
  • xcodebuild test -testPlan MacMagazine passed, including the new WebViewLoadPolicy Tests Swift Testing suite (9 cases)
  • swiftlint lint --strict — 0 violations in 241 files
  • ✅ Manually verified on simulator: reading position preserved after returning from external Safari and from the inline browser; foreground light/dark switching still reloads with the correct scheme

🤖 Generated with Claude Code

cassio-rossi and others added 2 commits July 18, 2026 14:31
Skip the redundant page load when a covered article's task restarts on
pop-back, and ignore colorScheme changes fired while the scene is not
active (app-switcher snapshot renders), reconciling a genuine appearance
change on return to foreground.

Co-Authored-By: Claude <noreply@anthropic.com>
@cassio-rossi
cassio-rossi merged commit 627a0b1 into release/v5 Jul 18, 2026
2 checks passed
@cassio-rossi
cassio-rossi deleted the fix/webview-reading-position branch July 18, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Posição de leitura ao retornar ao app

1 participant