Skip to content

fix(#316): hide ads when opening a post via widget, push, deeplink, or shortcut#317

Merged
cassio-rossi merged 2 commits into
release/v5from
fix/deeplink-removeads-cookie
Jul 21, 2026
Merged

fix(#316): hide ads when opening a post via widget, push, deeplink, or shortcut#317
cassio-rossi merged 2 commits into
release/v5from
fix/deeplink-removeads-cookie

Conversation

@cassio-rossi

Copy link
Copy Markdown
Collaborator

Closes #316

Problem

Opening a post from in-app navigation correctly hides ads for users who purchased ad removal. Opening the same post via widget, push notification, deeplink, or Home Screen shortcut still shows ads.

Root cause

Ad removal is driven by the patr cookie, written by MMWebView from @Environment(\.removeAds) (MMWebView.swift:7, 182-187). Default value is false (EnvironmentValuesExtensions.swift:26).

\.removeAds is injected only on the MainView subtree (MacMagazineApp.swift:134). All four external entry points set viewModel.deepLinkPostURL, presented by a single .fullScreenCover attached at the SceneView.body level (MacMagazineApp.swift:55-66) — a sibling of MainView, not a descendant. So DeepLinkNewsDetailViewMMWebView read the default false and wrote patr="false", showing ads.

\.theme is injected at the body level, which is why the deeplink article was themed correctly but ads were not hidden — a confirming detail.

Fix

Re-inject \.removeAds on the fullScreenCover content, alongside the modelContainer and analytics dependencies already re-injected there. One line fixes all four entry points, since they share one presentation.

DeepLinkNewsDetailView(url: url) { viewModel.deepLinkPostURL = nil }
    .modelContainer(viewModel.storage.sharedModelContainer)
    .environment(\.removeAds, viewModel.settingsViewModel.removeAds)   // added
    .environmentObject(viewModel.analytics)

Paths covered (all share the same cover)

  • Widget / deeplink — onOpenURL (MacMagazineApp.swift:48)
  • Push — newContentAvailable + cold-launch .task (MacMagazineApp.swift:76,104)
  • Shortcut — shortcutManager.url (MacMagazineApp.swift:85)

Testing

  • The cookie contract this relies on is already covered by CookiesTests.makeCookiesRemoveAds / makeCookiesNoRemoveAds. The fix itself is SwiftUI environment-tree wiring (not unit-testable per .claude/rules/testing.md), so no new test was added.
  • Build succeeded (iPhone 17 Pro Max sim, OS 26.5 — iPhone 17 Pro not installed on this machine).
  • Full MacMagazine test plan: 491 passed, 0 failed.
  • swiftlint --strict: 0 violations.

🤖 Generated with Claude Code

cassio-rossi and others added 2 commits July 21, 2026 21:37
…r shortcut

The deeplink fullScreenCover is presented at the SceneView.body level, a
sibling of MainView, so it did not inherit the \.removeAds environment value
that is injected only on the MainView subtree. MMWebView therefore read the
default (false) and wrote patr="false", showing ads to purchasing users.

Re-inject \.removeAds on the cover content alongside modelContainer and
analytics, which are already re-injected there. All four external entry points
share this single presentation, so this fixes every path at once.

Co-Authored-By: Claude <noreply@anthropic.com>
@cassio-rossi
cassio-rossi merged commit b061d1c into release/v5 Jul 21, 2026
2 checks passed
@cassio-rossi
cassio-rossi deleted the fix/deeplink-removeads-cookie branch July 21, 2026 21:04
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.

Ads not hidden when opening a post via widget, push, deeplink, or shortcut

1 participant