Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue sending the duckPlayerWatchOnYoutube pixel #3114

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions DuckDuckGo/Tab/TabExtensions/DuckPlayerTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ extension DuckPlayerTabExtension: NavigationResponder {

// “Watch in YouTube” selected
// when currently displayed content is the Duck Player and loading a YouTube URL, don‘t override it
if navigationAction.targetFrame?.url.isDuckPlayer == true,
navigationAction.targetFrame?.url.youtubeVideoID == videoID {
if didUserSelectWatchInYoutubeFromDuckPlayer(navigationAction, preferences: preferences, videoID: videoID) {
PixelKit.fire(GeneralPixel.duckPlayerWatchOnYoutube)
return .next

Expand Down Expand Up @@ -344,6 +343,11 @@ extension DuckPlayerTabExtension: NavigationResponder {
return .next
}

private func didUserSelectWatchInYoutubeFromDuckPlayer(_ navigationAction: NavigationAction, preferences: DuckPlayerPreferences, videoID: String) -> Bool {
let url = preferences.duckPlayerOpenInNewTab ? navigationAction.sourceFrame.url : navigationAction.targetFrame?.url
return url?.isDuckPlayer == true && url?.youtubeVideoID == videoID
}

func didCommit(_ navigation: Navigation) {
guard duckPlayer.isAvailable, duckPlayer.mode != .disabled else {
return
Expand Down
Loading