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

Break DuckPlayer ref cycle #3206

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import WebKit

protocol DuckNavigationHandling {
protocol DuckNavigationHandling: AnyObject {
var referrer: DuckPlayerReferrer { get set }
var duckPlayer: DuckPlayerProtocol { get }
func handleNavigation(_ navigationAction: WKNavigationAction, webView: WKWebView)
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public enum DuckPlayerReferrer {
case youtube, other
}

protocol DuckPlayerProtocol {
protocol DuckPlayerProtocol: AnyObject {

var settings: DuckPlayerSettingsProtocol { get }
var hostView: UIViewController? { get }
Expand All @@ -103,7 +103,7 @@ final class DuckPlayer: DuckPlayerProtocol {
static let commonName = "Duck Player"

private(set) var settings: DuckPlayerSettingsProtocol
private(set) var hostView: UIViewController?
private(set) weak var hostView: UIViewController?

init(settings: DuckPlayerSettingsProtocol = DuckPlayerSettings()) {
self.settings = settings
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ enum DuckPlayerMode: Equatable, Codable, CustomStringConvertible, CaseIterable {
}
}

protocol DuckPlayerSettingsProtocol {
protocol DuckPlayerSettingsProtocol: AnyObject {

var duckPlayerSettingsPublisher: AnyPublisher<Void, Never> { get }
var mode: DuckPlayerMode { get }
Expand Down
10 changes: 6 additions & 4 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class TabViewController: UIViewController {
bookmarksDatabase: CoreDataDatabase,
historyManager: HistoryManaging,
syncService: DDGSyncing,
duckPlayer: DuckPlayerProtocol,
duckPlayer: DuckPlayerProtocol?,
privacyProDataReporter: PrivacyProDataReporting,
contextualOnboardingPresenter: ContextualOnboardingPresenting,
contextualOnboardingLogic: ContextualOnboardingLogic,
Expand Down Expand Up @@ -323,7 +323,7 @@ class TabViewController: UIViewController {

let historyManager: HistoryManaging
let historyCapture: HistoryCapture
var duckPlayer: DuckPlayerProtocol
weak var duckPlayer: DuckPlayerProtocol?
var duckPlayerNavigationHandler: DuckNavigationHandling?

let contextualOnboardingPresenter: ContextualOnboardingPresenting
Expand All @@ -336,7 +336,7 @@ class TabViewController: UIViewController {
bookmarksDatabase: CoreDataDatabase,
historyManager: HistoryManaging,
syncService: DDGSyncing,
duckPlayer: DuckPlayerProtocol,
duckPlayer: DuckPlayerProtocol?,
privacyProDataReporter: PrivacyProDataReporting,
contextualOnboardingPresenter: ContextualOnboardingPresenting,
contextualOnboardingLogic: ContextualOnboardingLogic,
Expand All @@ -348,7 +348,9 @@ class TabViewController: UIViewController {
self.historyCapture = HistoryCapture(historyManager: historyManager)
self.syncService = syncService
self.duckPlayer = duckPlayer
self.duckPlayerNavigationHandler = DuckPlayerNavigationHandler(duckPlayer: duckPlayer)
if let duckPlayer {
self.duckPlayerNavigationHandler = DuckPlayerNavigationHandler(duckPlayer: duckPlayer)
}
self.privacyProDataReporter = privacyProDataReporter
self.contextualOnboardingPresenter = contextualOnboardingPresenter
self.contextualOnboardingLogic = contextualOnboardingLogic
Expand Down
Loading