From fa0a381d3a162921c97741b4b3ff0e684352f91c Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Thu, 9 May 2024 09:27:39 +0200 Subject: [PATCH] Fire a pixel directly from PreferencesDuckPlayerView --- .../Preferences/Model/DuckPlayerPreferences.swift | 10 ---------- .../Preferences/View/PreferencesDuckPlayerView.swift | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/DuckDuckGo/Preferences/Model/DuckPlayerPreferences.swift b/DuckDuckGo/Preferences/Model/DuckPlayerPreferences.swift index 2537bb71ec..d91123d78e 100644 --- a/DuckDuckGo/Preferences/Model/DuckPlayerPreferences.swift +++ b/DuckDuckGo/Preferences/Model/DuckPlayerPreferences.swift @@ -49,16 +49,6 @@ final class DuckPlayerPreferences: ObservableObject { var duckPlayerMode: DuckPlayerMode { didSet { persistor.duckPlayerModeBool = duckPlayerMode.boolValue - if oldValue != duckPlayerMode { - switch duckPlayerMode { - case .enabled: - PixelKit.fire(GeneralPixel.duckPlayerSettingAlwaysSettings) - case .alwaysAsk: - PixelKit.fire(GeneralPixel.duckPlayerSettingBackToDefault) - case .disabled: - PixelKit.fire(GeneralPixel.duckPlayerSettingNeverSettings) - } - } } } diff --git a/DuckDuckGo/Preferences/View/PreferencesDuckPlayerView.swift b/DuckDuckGo/Preferences/View/PreferencesDuckPlayerView.swift index 5d53b04bd7..d2549ade5c 100644 --- a/DuckDuckGo/Preferences/View/PreferencesDuckPlayerView.swift +++ b/DuckDuckGo/Preferences/View/PreferencesDuckPlayerView.swift @@ -17,6 +17,7 @@ // import PreferencesViews +import PixelKit import SwiftUI import SwiftUIExtensions @@ -30,6 +31,14 @@ extension Preferences { model.duckPlayerMode } set: { newValue in model.duckPlayerMode = newValue + switch model.duckPlayerMode { + case .enabled: + PixelKit.fire(GeneralPixel.duckPlayerSettingAlwaysSettings) + case .alwaysAsk: + PixelKit.fire(GeneralPixel.duckPlayerSettingBackToDefault) + case .disabled: + PixelKit.fire(GeneralPixel.duckPlayerSettingNeverSettings) + } } }