diff --git a/DuckDuckGo/BrokenSiteInfo.swift b/DuckDuckGo/BrokenSiteInfo.swift index 9a1ed49e6e..fc516b48ef 100644 --- a/DuckDuckGo/BrokenSiteInfo.swift +++ b/DuckDuckGo/BrokenSiteInfo.swift @@ -104,7 +104,7 @@ public struct BrokenSiteInfo { Keys.manufacturer: manufacturer, Keys.model: model, Keys.gpc: gpc ? "true" : "false", - Keys.ampUrl: ampUrl ?? "", + Keys.ampUrl: normalize(URL(string: ampUrl ?? "")), Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false", Keys.protectionsState: protectionsState ? "true" : "false" ] diff --git a/DuckDuckGo/HomeViewController.swift b/DuckDuckGo/HomeViewController.swift index 4f97f8c46b..c90a9ac317 100644 --- a/DuckDuckGo/HomeViewController.swift +++ b/DuckDuckGo/HomeViewController.swift @@ -63,42 +63,64 @@ class HomeViewController: UIViewController { private let tabModel: Tab private let favoritesViewModel: FavoritesListInteracting + private let appSettings: AppSettings private var viewModelCancellable: AnyCancellable? + private var favoritesDisplayModeCancellable: AnyCancellable? #if APP_TRACKING_PROTECTION private let appTPHomeViewModel: AppTPHomeViewModel #endif #if APP_TRACKING_PROTECTION - static func loadFromStoryboard(model: Tab, favoritesViewModel: FavoritesListInteracting, appTPDatabase: CoreDataDatabase) -> HomeViewController { + static func loadFromStoryboard( + model: Tab, + favoritesViewModel: FavoritesListInteracting, + appSettings: AppSettings, + appTPDatabase: CoreDataDatabase + ) -> HomeViewController { + let storyboard = UIStoryboard(name: "Home", bundle: nil) let controller = storyboard.instantiateViewController(identifier: "HomeViewController", creator: { coder in - HomeViewController(coder: coder, tabModel: model, favoritesViewModel: favoritesViewModel, appTPDatabase: appTPDatabase) + HomeViewController( + coder: coder, + tabModel: model, + favoritesViewModel: favoritesViewModel, + appSettings: appSettings, + appTPDatabase: appTPDatabase + ) }) return controller } #else - static func loadFromStoryboard(model: Tab, favoritesViewModel: FavoritesListInteracting) -> HomeViewController { + static func loadFromStoryboard(model: Tab, favoritesViewModel: FavoritesListInteracting, appSettings: AppSettings) -> HomeViewController { let storyboard = UIStoryboard(name: "Home", bundle: nil) let controller = storyboard.instantiateViewController(identifier: "HomeViewController", creator: { coder in - HomeViewController(coder: coder, tabModel: model, favoritesViewModel: favoritesViewModel) + HomeViewController(coder: coder, tabModel: model, favoritesViewModel: favoritesViewModel, appSettings: appSettings) }) return controller } #endif #if APP_TRACKING_PROTECTION - required init?(coder: NSCoder, tabModel: Tab, favoritesViewModel: FavoritesListInteracting, appTPDatabase: CoreDataDatabase) { + required init?( + coder: NSCoder, + tabModel: Tab, + favoritesViewModel: FavoritesListInteracting, + appSettings: AppSettings, + appTPDatabase: CoreDataDatabase + ) { self.tabModel = tabModel self.favoritesViewModel = favoritesViewModel + self.appSettings = appSettings self.appTPHomeViewModel = AppTPHomeViewModel(appTrackingProtectionDatabase: appTPDatabase) super.init(coder: coder) } #else - required init?(coder: NSCoder, tabModel: Tab, favoritesViewModel: FavoritesListInteracting) { + required init?(coder: NSCoder, tabModel: Tab, favoritesViewModel: FavoritesListInteracting, appSettings: AppSettings) { self.tabModel = tabModel self.favoritesViewModel = favoritesViewModel + self.appSettings = appSettings super.init(coder: coder) } @@ -133,6 +155,16 @@ class HomeViewController: UIViewController { self.delegate?.home(self, didRequestHideLogo: false) } } + + favoritesDisplayModeCancellable = NotificationCenter.default.publisher(for: AppUserDefaults.Notifications.favoritesDisplayModeChange) + .receive(on: DispatchQueue.main) + .sink { [weak self] _ in + guard let self else { + return + } + self.favoritesViewModel.favoritesDisplayMode = self.appSettings.favoritesDisplayMode + self.collectionView.reloadData() + } } @objc func bookmarksDidChange() { diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index ebd8cfd37a..bbc4f9f9d3 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -645,9 +645,10 @@ class MainViewController: UIViewController { #if APP_TRACKING_PROTECTION let controller = HomeViewController.loadFromStoryboard(model: tabModel!, favoritesViewModel: favoritesViewModel, + appSettings: appSettings, appTPDatabase: appTrackingProtectionDatabase) #else - let controller = HomeViewController.loadFromStoryboard(model: tabModel!, favoritesViewModel: favoritesViewModel) + let controller = HomeViewController.loadFromStoryboard(model: tabModel!, favoritesViewModel: favoritesViewModel, appSettings: appSettings) #endif homeController = controller diff --git a/LocalPackages/SyncUI/Package.swift b/LocalPackages/SyncUI/Package.swift index f8193ce7ef..f95f0f7cc2 100644 --- a/LocalPackages/SyncUI/Package.swift +++ b/LocalPackages/SyncUI/Package.swift @@ -31,13 +31,15 @@ let package = Package( targets: ["SyncUI"]) ], dependencies: [ - .package(path: "../DuckUI") + .package(path: "../DuckUI"), + .package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0") ], targets: [ .target( name: "SyncUI", dependencies: [ - .product(name: "DuckUI", package: "DuckUI") + .product(name: "DuckUI", package: "DuckUI"), + "DesignResourcesKit" ]) ] ) diff --git a/submodules/privacy-reference-tests b/submodules/privacy-reference-tests index 0d23f76801..7519c3d430 160000 --- a/submodules/privacy-reference-tests +++ b/submodules/privacy-reference-tests @@ -1 +1 @@ -Subproject commit 0d23f76801c2e73ae7d5ed7daa4af4aca5beec73 +Subproject commit 7519c3d430e5dcef75b6128bfdadb0de3f463a49