fix(#316): hide ads when opening a post via widget, push, deeplink, or shortcut#317
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
patrcookie, written byMMWebViewfrom@Environment(\.removeAds)(MMWebView.swift:7,182-187). Default value isfalse(EnvironmentValuesExtensions.swift:26).\.removeAdsis injected only on theMainViewsubtree (MacMagazineApp.swift:134). All four external entry points setviewModel.deepLinkPostURL, presented by a single.fullScreenCoverattached at theSceneView.bodylevel (MacMagazineApp.swift:55-66) — a sibling ofMainView, not a descendant. SoDeepLinkNewsDetailView→MMWebViewread the defaultfalseand wrotepatr="false", showing ads.\.themeis 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
\.removeAdson the fullScreenCover content, alongside themodelContainerandanalyticsdependencies already re-injected there. One line fixes all four entry points, since they share one presentation.Paths covered (all share the same cover)
onOpenURL(MacMagazineApp.swift:48)newContentAvailable+ cold-launch.task(MacMagazineApp.swift:76,104)shortcutManager.url(MacMagazineApp.swift:85)Testing
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.MacMagazinetest plan: 491 passed, 0 failed.swiftlint --strict: 0 violations.🤖 Generated with Claude Code