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

Duckplayer New Tab + Refactor #3491

Merged
merged 35 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fc19ec0
DuckPlayer Refactor + Open in New tab Initial Changes
afterxleep Oct 27, 2024
6e9cc06
Remove DuckPlayer Launch Experiment
afterxleep Oct 27, 2024
a757070
Cleanup DuckplayerNavigation handler on Tab Dismissal
afterxleep Oct 27, 2024
f69c38e
Adds a delay to the webView.url keyvalue observer
afterxleep Oct 27, 2024
39984ab
Implement handleDidStartLoading and handleDidFinishLoading
afterxleep Oct 27, 2024
1b38ce2
Open videos from YoutubeWatch URLs in new tab if needed
afterxleep Oct 27, 2024
f3acdd0
DuckPlayer Open in New tab - Cleanup & Optimizations
afterxleep Oct 27, 2024
6b932f7
Added Documentation
afterxleep Oct 27, 2024
d74572b
Correctly hide DuckPlayer icon when navigating away
afterxleep Oct 28, 2024
f741669
Updated DuckPlayer documentation and references
afterxleep Oct 28, 2024
9b93882
Prevent Youtube app from opening with DuckPlayer
afterxleep Oct 28, 2024
5485349
Improved DuckPlayer tests for pixels and navigation
afterxleep Oct 28, 2024
e664ca4
Merge branch 'main' into daniel/duckplayer.refactor.new.tab
afterxleep Oct 28, 2024
ae1d2b0
Resolve conflicts
afterxleep Oct 28, 2024
a968bab
Lint fixes
afterxleep Oct 28, 2024
dd16e4b
Refactored isNewTab method and added tests
afterxleep Oct 29, 2024
eb82394
Fix omnibar icon
afterxleep Oct 29, 2024
4e1f84d
Properly handle reloads
afterxleep Oct 29, 2024
3bc769b
Fix reload behavior
afterxleep Oct 29, 2024
bf0eb6c
Updated tests and fixed failure
afterxleep Oct 29, 2024
ed6b060
Allow Youtube app links
afterxleep Oct 29, 2024
9e628b3
Reviewed Pixels and updated events
afterxleep Oct 29, 2024
f366dc1
Disable Allow First Video on load completo and add a fallback
afterxleep Oct 29, 2024
9433591
Remember my choice pixels
afterxleep Oct 29, 2024
a94c498
Update SERP and YT overlay pixel logic
afterxleep Oct 30, 2024
712ab28
Bump BSK
afterxleep Oct 30, 2024
056bfe8
Include telemetry events
afterxleep Oct 30, 2024
757a5b5
Merge branch 'main' into daniel/duckplayer.refactor.new.tab
afterxleep Oct 30, 2024
c1f901d
Reduce Allow first video time
afterxleep Oct 31, 2024
5f6348f
Lint fixes
afterxleep Oct 31, 2024
8912858
Removed unused stuff
afterxleep Oct 31, 2024
106f19b
Removed pixel tests
afterxleep Oct 31, 2024
8cad60a
Use the latest C.S.S
afterxleep Nov 1, 2024
79367b3
Update Translation String
afterxleep Nov 1, 2024
acbe25b
Fix lint issues
afterxleep Nov 1, 2024
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
3 changes: 1 addition & 2 deletions DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
private func fireDuckPlayerPixels(webView: WKWebView) {

// First daily unique user Duck Player view
dailyPixelFiring.fireDaily(.duckPlayerDailyUniqueView, withAdditionalParameters: ["settings": duckPlayerMode.stringValue])

Check failure on line 304 in DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)

// Duck Player viewed with Always setting, referred from YouTube (automatic)
if (referrer == .youtube) && duckPlayerMode == .enabled {
Expand Down Expand Up @@ -525,7 +525,7 @@
}



Check failure on line 528 in DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Limit vertical whitespace to maximum 2 empty lines; currently 3 (vertical_whitespace)
}

/// Determines if the current tab is a new tab based on the targetFrame request and other params
Expand Down Expand Up @@ -560,7 +560,7 @@
/// - navigationAction: The `WKNavigationAction` to handle.
/// - webView: The `WKWebView` where navigation is occurring.
@MainActor
func handleDuckNavigation(_ navigationAction: WKNavigationAction, webView: WKWebView) {

Check failure on line 563 in DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Function should have complexity 10 or less; currently complexity is 12 (cyclomatic_complexity)

Logger.duckPlayer.debug("Handling Navigation for \(webView.url?.absoluteString ?? "")")

Expand Down Expand Up @@ -648,7 +648,7 @@
/// - Parameter webView: The `WKWebView` whose URL has changed.
/// - Returns: A result indicating whether the URL change was handled.
@MainActor
func handleURLChange(webView: WKWebView) -> DuckPlayerNavigationHandlerURLChangeResult {

Check failure on line 651 in DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Function should have complexity 10 or less; currently complexity is 11 (cyclomatic_complexity)

// We want to prevent multiple simultaneous redirects
// This can be caused by Duplicate Nav events, and quick URL changes
Expand Down Expand Up @@ -793,7 +793,6 @@
func handleAttach(webView: WKWebView) {

// Reset referrer and initial settings
duckPlayer.settings.allowFirstVideo = false
referrer = .other

// Ensure feature and mode are enabled
Expand Down Expand Up @@ -836,7 +835,7 @@
// This is a fallback as the WKNavigation Delegate does not
// Always fires finishLoading (For JS Navigation) which
// triggers handleDidFinishLoading
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.duckPlayer.settings.allowFirstVideo = false
}

Expand Down Expand Up @@ -880,7 +879,7 @@
return false
}

let parameters = getDuckPlayerParameters(url: url)

Check failure on line 882 in DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)

// Only account for in 'Always' mode
if duckPlayerMode == .disabled {
Expand Down
6 changes: 5 additions & 1 deletion DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ final class DuckPlayerSettingsDefault: DuckPlayerSettings {
}

/// Flag to allow the first video to play without redirection.
var allowFirstVideo: Bool = false
var allowFirstVideo: Bool = false {
didSet {
print("DP: Allow first video: \(allowFirstVideo)")
afterxleep marked this conversation as resolved.
Show resolved Hide resolved
}
}

/// Determines if Duck Player should open videos in a new tab.
var openInNewTab: Bool {
Expand Down
Loading