Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add the autocomplete settings toggle pixels #2991

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions DuckDuckGo/PrivateSearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/SettingsGeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 26 additions & 1 deletion DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Subscription
import NetworkProtection
#endif

// swiftlint:disable type_body_length
final class SettingsViewModel: ObservableObject {

// Dependencies
Expand Down Expand Up @@ -154,13 +155,36 @@ final class SettingsViewModel: ObservableObject {
)
}

var autocompleteBinding: Binding<Bool> {
var autocompleteGeneralBinding: Binding<Bool> {
Binding<Bool>(
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<Bool> {
Binding<Bool>(
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)
}
}
)
}
Expand Down Expand Up @@ -321,6 +345,7 @@ final class SettingsViewModel: ObservableObject {
subscriptionSignOutObserver = nil
}
}
// swiftlint:enable type_body_length

// MARK: Private methods
extension SettingsViewModel {
Expand Down
Loading