diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index d1a2fd2e36..14a110450f 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -128,6 +128,7 @@ class MainViewController: UIViewController { private lazy var featureFlagger = AppDependencyProvider.shared.featureFlagger private lazy var faviconLoader: FavoritesFaviconLoading = FavoritesFaviconLoader() + private lazy var faviconsFetcherOnboarding = FaviconsFetcherOnboarding(syncService: syncService, syncBookmarksAdapter: syncDataProviders.bookmarksAdapter) lazy var menuBookmarksViewModel: MenuBookmarksInteracting = { let viewModel = MenuBookmarksViewModel(bookmarksDatabase: bookmarksDatabase, syncService: syncService) @@ -795,8 +796,6 @@ class MainViewController: UIViewController { let controller = NewTabPageViewController(tab: tabModel, isNewTabPageCustomizationEnabled: homeTabManager.isNewTabPageSectionsEnabled, interactionModel: favoritesViewModel, - syncService: syncService, - syncBookmarksAdapter: syncDataProviders.bookmarksAdapter, homePageMessagesConfiguration: homePageConfiguration, privacyProDataReporting: privacyProDataReporter, variantManager: variantManager, @@ -2172,6 +2171,10 @@ extension MainViewController: NewTabPageControllerDelegate { func newTabPageDidDeleteFavorite(_ controller: NewTabPageViewController, favorite: BookmarkEntity) { // no-op for now } + + func newTabPageDidRequestFaviconsFetcherOnboarding(_ controller: NewTabPageViewController) { + faviconsFetcherOnboarding.presentOnboardingIfNeeded(from: self) + } } extension MainViewController: NewTabPageControllerShortcutsDelegate { diff --git a/DuckDuckGo/NewTabPageControllerDelegate.swift b/DuckDuckGo/NewTabPageControllerDelegate.swift index 08ecc46c65..d36758dc58 100644 --- a/DuckDuckGo/NewTabPageControllerDelegate.swift +++ b/DuckDuckGo/NewTabPageControllerDelegate.swift @@ -24,6 +24,7 @@ protocol NewTabPageControllerDelegate: AnyObject { func newTabPageDidOpenFavoriteURL(_ controller: NewTabPageViewController, url: URL) func newTabPageDidDeleteFavorite(_ controller: NewTabPageViewController, favorite: BookmarkEntity) func newTabPageDidEditFavorite(_ controller: NewTabPageViewController, favorite: BookmarkEntity) + func newTabPageDidRequestFaviconsFetcherOnboarding(_ controller: NewTabPageViewController) } protocol NewTabPageControllerShortcutsDelegate: AnyObject { diff --git a/DuckDuckGo/NewTabPageViewController.swift b/DuckDuckGo/NewTabPageViewController.swift index 4bac3ed5b9..b59719e372 100644 --- a/DuckDuckGo/NewTabPageViewController.swift +++ b/DuckDuckGo/NewTabPageViewController.swift @@ -25,14 +25,10 @@ import Core final class NewTabPageViewController: UIHostingController, NewTabPage { - private let syncService: DDGSyncing - private let syncBookmarksAdapter: SyncBookmarksAdapter private let variantManager: VariantManager private let newTabDialogFactory: any NewTabDaxDialogProvider private let newTabDialogTypeProvider: NewTabDialogSpecProvider - private(set) lazy var faviconsFetcherOnboarding = FaviconsFetcherOnboarding(syncService: syncService, syncBookmarksAdapter: syncBookmarksAdapter) - private let newTabPageViewModel: NewTabPageViewModel private let messagesModel: NewTabPageMessagesModel private let favoritesModel: FavoritesViewModel @@ -53,8 +49,6 @@ final class NewTabPageViewController: UIHostingController, NewTabPage { init(tab: Tab, isNewTabPageCustomizationEnabled: Bool, interactionModel: FavoritesListInteracting, - syncService: DDGSyncing, - syncBookmarksAdapter: SyncBookmarksAdapter, homePageMessagesConfiguration: HomePageMessagesConfiguration, privacyProDataReporting: PrivacyProDataReporting? = nil, variantManager: VariantManager, @@ -63,8 +57,6 @@ final class NewTabPageViewController: UIHostingController, NewTabPage { faviconLoader: FavoritesFaviconLoading) { self.associatedTab = tab - self.syncService = syncService - self.syncBookmarksAdapter = syncBookmarksAdapter self.variantManager = variantManager self.newTabDialogFactory = newTabDialogFactory self.newTabDialogTypeProvider = newTabDialogTypeProvider @@ -145,7 +137,8 @@ final class NewTabPageViewController: UIHostingController, NewTabPage { private func assignFavoriteModelActions() { favoritesModel.onFaviconMissing = { [weak self] in guard let self else { return } - self.faviconsFetcherOnboarding.presentOnboardingIfNeeded(from: self) + + delegate?.newTabPageDidRequestFaviconsFetcherOnboarding(self) } favoritesModel.onFavoriteURLSelected = { [weak self] url in diff --git a/DuckDuckGoTests/NewTabPageControllerDaxDialogTests.swift b/DuckDuckGoTests/NewTabPageControllerDaxDialogTests.swift index 440a2934df..1c6322925e 100644 --- a/DuckDuckGoTests/NewTabPageControllerDaxDialogTests.swift +++ b/DuckDuckGoTests/NewTabPageControllerDaxDialogTests.swift @@ -38,14 +38,7 @@ final class NewTabPageControllerDaxDialogTests: XCTestCase { variantManager = CapturingVariantManager() dialogFactory = CapturingNewTabDaxDialogProvider() specProvider = MockNewTabDialogSpecProvider() - let dataProviders = SyncDataProviders( - bookmarksDatabase: db, - secureVaultFactory: AutofillSecureVaultFactory, - secureVaultErrorReporter: SecureVaultReporter(), - settingHandlers: [], - favoritesDisplayModeStorage: MockFavoritesDisplayModeStoring(), - syncErrorHandler: SyncErrorHandler() - ) + let remoteMessagingClient = RemoteMessagingClient( bookmarksDatabase: db, appSettings: AppSettingsMock(), @@ -60,8 +53,6 @@ final class NewTabPageControllerDaxDialogTests: XCTestCase { tab: Tab(), isNewTabPageCustomizationEnabled: false, interactionModel: MockFavoritesListInteracting(), - syncService: MockDDGSyncing(authState: .active, isSyncInProgress: false), - syncBookmarksAdapter: dataProviders.bookmarksAdapter, homePageMessagesConfiguration: homePageConfiguration, variantManager: variantManager, newTabDialogFactory: dialogFactory,