Skip to content

Commit

Permalink
Merge branch 'develop' into sam/hack-days-netp-widget
Browse files Browse the repository at this point in the history
* develop:
  Normalize ampUrl in breakage pixel (#2154)
  Bump submodules/privacy-reference-tests from `0d23f76` to `7519c3d` (#2135)
  Properly refresh home page favorites view when updating favorites display mode (#2148)
  Add DesignResourcesKit to SyncUI (#2147)
  • Loading branch information
samsymons committed Nov 13, 2023
2 parents 69f284a + 20176c4 commit 0fd5b77
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/BrokenSiteInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
44 changes: 38 additions & 6 deletions DuckDuckGo/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
])
]
)

0 comments on commit 0fd5b77

Please sign in to comment.