From cd353e21ffb56e1e2a875bf50f8ba7a10a3d1b9e Mon Sep 17 00:00:00 2001 From: Daniel Bernal Date: Wed, 7 Aug 2024 23:47:38 +0200 Subject: [PATCH] Update references in TabViewController --- DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift | 2 +- DuckDuckGo/DuckPlayer/DuckPlayer.swift | 2 +- DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift | 2 +- DuckDuckGo/TabViewController.swift | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift b/DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift index 25365d0266..6bb9af7d13 100644 --- a/DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift +++ b/DuckDuckGo/DuckPlayer/DuckNavigationHandling.swift @@ -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) diff --git a/DuckDuckGo/DuckPlayer/DuckPlayer.swift b/DuckDuckGo/DuckPlayer/DuckPlayer.swift index 6284c041de..62f974265b 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayer.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayer.swift @@ -78,7 +78,7 @@ public enum DuckPlayerReferrer { case youtube, other } -protocol DuckPlayerProtocol { +protocol DuckPlayerProtocol: AnyObject { var settings: DuckPlayerSettingsProtocol { get } var hostView: UIViewController? { get } diff --git a/DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift b/DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift index 5e2a43d7bb..b187b2cb1e 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayerSettings.swift @@ -64,7 +64,7 @@ enum DuckPlayerMode: Equatable, Codable, CustomStringConvertible, CaseIterable { } } -protocol DuckPlayerSettingsProtocol { +protocol DuckPlayerSettingsProtocol: AnyObject { var duckPlayerSettingsPublisher: AnyPublisher { get } var mode: DuckPlayerMode { get } diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index 6a326deb5e..92327ec970 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -294,7 +294,7 @@ class TabViewController: UIViewController { bookmarksDatabase: CoreDataDatabase, historyManager: HistoryManaging, syncService: DDGSyncing, - duckPlayer: DuckPlayerProtocol, + duckPlayer: DuckPlayerProtocol?, privacyProDataReporter: PrivacyProDataReporting, contextualOnboardingPresenter: ContextualOnboardingPresenting, contextualOnboardingLogic: ContextualOnboardingLogic, @@ -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 @@ -336,7 +336,7 @@ class TabViewController: UIViewController { bookmarksDatabase: CoreDataDatabase, historyManager: HistoryManaging, syncService: DDGSyncing, - duckPlayer: DuckPlayerProtocol, + duckPlayer: DuckPlayerProtocol?, privacyProDataReporter: PrivacyProDataReporting, contextualOnboardingPresenter: ContextualOnboardingPresenting, contextualOnboardingLogic: ContextualOnboardingLogic, @@ -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