Skip to content

Commit

Permalink
Fix issues with dismissing favicon fetcher tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
dus7 committed Nov 4, 2024
1 parent 50bf23e commit 51b5173
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
7 changes: 5 additions & 2 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/NewTabPageControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 2 additions & 9 deletions DuckDuckGo/NewTabPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ import Core

final class NewTabPageViewController: UIHostingController<AnyView>, 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
Expand All @@ -53,8 +49,6 @@ final class NewTabPageViewController: UIHostingController<AnyView>, NewTabPage {
init(tab: Tab,
isNewTabPageCustomizationEnabled: Bool,
interactionModel: FavoritesListInteracting,
syncService: DDGSyncing,
syncBookmarksAdapter: SyncBookmarksAdapter,
homePageMessagesConfiguration: HomePageMessagesConfiguration,
privacyProDataReporting: PrivacyProDataReporting? = nil,
variantManager: VariantManager,
Expand All @@ -63,8 +57,6 @@ final class NewTabPageViewController: UIHostingController<AnyView>, NewTabPage {
faviconLoader: FavoritesFaviconLoading) {

self.associatedTab = tab
self.syncService = syncService
self.syncBookmarksAdapter = syncBookmarksAdapter
self.variantManager = variantManager
self.newTabDialogFactory = newTabDialogFactory
self.newTabDialogTypeProvider = newTabDialogTypeProvider
Expand Down Expand Up @@ -145,7 +137,8 @@ final class NewTabPageViewController: UIHostingController<AnyView>, 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
Expand Down
11 changes: 1 addition & 10 deletions DuckDuckGoTests/NewTabPageControllerDaxDialogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down

0 comments on commit 51b5173

Please sign in to comment.