diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 12f59fcbbb..c975046346 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -656,12 +656,12 @@ extension Pixel { case settingsWebTrackingProtectionOpen case settingsGpcOn case settingsGpcOff - case settingsAutocompleteOn - case settingsAutocompleteOff - case settingsRecentlyVisitedOn - case settingsRecentlyVisitedOff case settingsGeneralAutocompleteOn case settingsGeneralAutocompleteOff + case settingsPrivateSearchAutocompleteOn + case settingsPrivateSearchAutocompleteOff + case settingsRecentlyVisitedOn + case settingsRecentlyVisitedOff case settingsAddressBarSelectorPressed case settingsAccessibilityOpen case settingsAccessiblityTextSize @@ -1335,12 +1335,12 @@ extension Pixel.Event { case .settingsWebTrackingProtectionOpen: return "m_settings_web_tracking_protection_open" case .settingsGpcOn: return "m_settings_gpc_on" case .settingsGpcOff: return "m_settings_gpc_off" - case .settingsAutocompleteOn: return "m_settings_autocomplete_on" - case .settingsAutocompleteOff: return "m_settings_autocomplete_off" - case .settingsRecentlyVisitedOn: return "m_settings_autocomplete_recently-visited_on" - case .settingsRecentlyVisitedOff: return "m_settings_autocomplete_recently-visited_off" case .settingsGeneralAutocompleteOn: return "m_settings_general_autocomplete_on" case .settingsGeneralAutocompleteOff: return "m_settings_general_autocomplete_off" + case .settingsPrivateSearchAutocompleteOn: return "m_settings_private_search_autocomplete_on" + case .settingsPrivateSearchAutocompleteOff: return "m_settings_private_search_autocomplete_off" + case .settingsRecentlyVisitedOn: return "m_settings_autocomplete_recently-visited_on" + case .settingsRecentlyVisitedOff: return "m_settings_autocomplete_recently-visited_off" case .settingsAddressBarSelectorPressed: return "m_settings_address_bar_selector_pressed" case .settingsAccessibilityOpen: return "m_settings_accessibility_open" case .settingsAccessiblityTextSize: return "m_settings_accessiblity_text_size" diff --git a/DuckDuckGo/PrivateSearchView.swift b/DuckDuckGo/PrivateSearchView.swift index f42c3e990d..a16218a4a8 100644 --- a/DuckDuckGo/PrivateSearchView.swift +++ b/DuckDuckGo/PrivateSearchView.swift @@ -51,10 +51,9 @@ struct PrivateSearchViewSettings: View { Section(footer: Text(UserText.settingsAutocompleteSubtitle)) { // Autocomplete Suggestions SettingsCellView(label: UserText.settingsAutocompleteLabel, - accesory: .toggle(isOn: viewModel.autocompleteBinding)) + accesory: .toggle(isOn: viewModel.autocompletePrivateSearchBinding)) } - if viewModel.shouldShowRecentlyVisitedSites { Section(footer: Text(UserText.settingsAutocompleteRecentlyVisitedSubtitle)) { SettingsCellView(label: UserText.settingsAutocompleteRecentlyVisitedLabel, diff --git a/DuckDuckGo/SettingsGeneralView.swift b/DuckDuckGo/SettingsGeneralView.swift index 6e528bf084..5f51165375 100644 --- a/DuckDuckGo/SettingsGeneralView.swift +++ b/DuckDuckGo/SettingsGeneralView.swift @@ -39,7 +39,7 @@ struct SettingsGeneralView: View { footer: Text(UserText.settingsAutocompleteSubtitle)) { // Autocomplete Suggestions SettingsCellView(label: UserText.settingsAutocompleteLabel, - accesory: .toggle(isOn: viewModel.autocompleteBinding)) + accesory: .toggle(isOn: viewModel.autocompleteGeneralBinding)) } if viewModel.shouldShowRecentlyVisitedSites { diff --git a/DuckDuckGo/SettingsViewModel.swift b/DuckDuckGo/SettingsViewModel.swift index 367c78da1e..228140d87b 100644 --- a/DuckDuckGo/SettingsViewModel.swift +++ b/DuckDuckGo/SettingsViewModel.swift @@ -31,6 +31,7 @@ import Subscription import NetworkProtection #endif +// swiftlint:disable type_body_length final class SettingsViewModel: ObservableObject { // Dependencies @@ -154,13 +155,36 @@ final class SettingsViewModel: ObservableObject { ) } - var autocompleteBinding: Binding { + var autocompleteGeneralBinding: Binding { Binding( get: { self.state.autocomplete }, set: { self.appSettings.autocomplete = $0 self.state.autocomplete = $0 self.updateRecentlyVisitedSitesVisibility() + + if $0 { + Pixel.fire(pixel: .settingsGeneralAutocompleteOn) + } else { + Pixel.fire(pixel: .settingsGeneralAutocompleteOff) + } + } + ) + } + + var autocompletePrivateSearchBinding: Binding { + Binding( + get: { self.state.autocomplete }, + set: { + self.appSettings.autocomplete = $0 + self.state.autocomplete = $0 + self.updateRecentlyVisitedSitesVisibility() + + if $0 { + Pixel.fire(pixel: .settingsPrivateSearchAutocompleteOn) + } else { + Pixel.fire(pixel: .settingsPrivateSearchAutocompleteOff) + } } ) } @@ -321,6 +345,7 @@ final class SettingsViewModel: ObservableObject { subscriptionSignOutObserver = nil } } +// swiftlint:enable type_body_length // MARK: Private methods extension SettingsViewModel {