Skip to content

Commit

Permalink
VPN status removed. Refreshing view when default browser changes fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Feb 25, 2024
1 parent be57d26 commit 2e368be
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions DuckDuckGo/HomePage/View/HomePageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ final class HomePageViewController: NSViewController {
}

func createDefaultBrowserModel() -> HomePage.Models.DefaultBrowserModel {
return .init(isDefault: DefaultBrowserPreferences().isDefault, wasClosed: defaultBrowserDismissed, requestSetDefault: { [weak self] in
let defaultBrowserPreferencesModel = DefaultBrowserPreferences()
return .init(isDefault: DefaultBrowserPreferences.shared.isDefault, wasClosed: defaultBrowserDismissed, requestSetDefault: { [weak self] in
let defaultBrowserPreferencesModel = DefaultBrowserPreferences.shared
defaultBrowserPreferencesModel.becomeDefault { [weak self] isDefault in
_ = defaultBrowserPreferencesModel
self?.defaultBrowserModel.isDefault = isDefault
Expand Down Expand Up @@ -196,7 +196,7 @@ final class HomePageViewController: NSViewController {
}

func refreshDefaultBrowserModel() {
let prefs = DefaultBrowserPreferences()
let prefs = DefaultBrowserPreferences.shared
if prefs.isDefault {
defaultBrowserDismissed = false
}
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/Preferences/Model/DefaultBrowserPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct SystemDefaultBrowserProvider: DefaultBrowserProvider {

final class DefaultBrowserPreferences: ObservableObject {

static let shared = DefaultBrowserPreferences()

@Published private(set) var isDefault: Bool = false {
didSet {
// Temporary pixel for first time user import data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class PrivacyProtectionStatus: ObservableObject {
static func status(for preferencePane: PreferencePaneIdentifier) -> PrivacyProtectionStatus {
switch preferencePane {
case .defaultBrowser:
return PrivacyProtectionStatus(statusPublisher: DefaultBrowserPreferences().$isDefault) { isDefault in
return PrivacyProtectionStatus(statusPublisher: DefaultBrowserPreferences.shared.$isDefault) { isDefault in
isDefault ? .on : .off
}
case .privateSearch:
Expand All @@ -44,10 +44,6 @@ final class PrivacyProtectionStatus: ObservableObject {
return PrivacyProtectionStatus(statusPublisher: publisher, initialValue: EmailManager().isSignedIn ? .on : .off) { _ in
EmailManager().isSignedIn ? .on : .off
}
case .vpn:
return PrivacyProtectionStatus(statusPublisher: VPNPreferencesModel().$showUninstallVPN) { showUninstallVPN in
showUninstallVPN ? .on : .off
}
default:
return PrivacyProtectionStatus()
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Preferences/View/PreferencesRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum Preferences {

switch model.selectedPane {
case .defaultBrowser:
DefaultBrowserView(defaultBrowserModel: DefaultBrowserPreferences())
DefaultBrowserView(defaultBrowserModel: DefaultBrowserPreferences.shared)
case .privateSearch:
PrivateSearchView(model: SearchPreferences.shared)
case .webTrackingProtection:
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ extension BrowserTabViewController: OnboardingDelegate {
}

func onboardingDidRequestSetDefault(completion: @escaping () -> Void) {
let defaultBrowserPreferences = DefaultBrowserPreferences()
let defaultBrowserPreferences = DefaultBrowserPreferences.shared
if defaultBrowserPreferences.isDefault {
completion()
return
Expand Down

0 comments on commit 2e368be

Please sign in to comment.