diff --git a/DuckDuckGo/AppLifecycle/AppStateTransitions.swift b/DuckDuckGo/AppLifecycle/AppStateTransitions.swift index a6e5a8160c..637e7b0a09 100644 --- a/DuckDuckGo/AppLifecycle/AppStateTransitions.swift +++ b/DuckDuckGo/AppLifecycle/AppStateTransitions.swift @@ -102,9 +102,6 @@ extension Background { extension DoubleBackground { func apply(event: AppEvent) -> any AppState { - // report event so we know what events can be called at this moment, but do not let SM be stuck in this state just not to be flooded with these events - _ = handleUnexpectedEvent(event) - switch event { case .activating(let application): return Active(application: application) @@ -123,9 +120,6 @@ extension DoubleBackground { extension InactiveBackground { func apply(event: AppEvent) -> any AppState { - // report event so we know what events can be called at this moment, but do not let SM be stuck in this state just not to be flooded with these events - _ = handleUnexpectedEvent(event) - switch event { case .activating(let application): return Active(application: application) diff --git a/DuckDuckGo/AppLifecycle/AppStates/Background.swift b/DuckDuckGo/AppLifecycle/AppStates/Background.swift index 316da5d511..f8ba893339 100644 --- a/DuckDuckGo/AppLifecycle/AppStates/Background.swift +++ b/DuckDuckGo/AppLifecycle/AppStates/Background.swift @@ -47,10 +47,13 @@ struct DoubleBackground: AppState { var parameters = [ PixelParameters.firstBackgroundTimestamp: dateFormatter.string(from: previousDidEnterBackgroundTimestamp), - PixelParameters.secondBackgroundTimestamp: dateFormatter.string(from: currentDidEnterBackgroundTimestamp), - PixelParameters.numberOfBackgrounds: String(counter) + PixelParameters.secondBackgroundTimestamp: dateFormatter.string(from: currentDidEnterBackgroundTimestamp) ] + if counter < 5 { + parameters[PixelParameters.numberOfBackgrounds] = String(counter) + } + func isValid(timestamp: Date) -> Bool { timestamp >= previousDidEnterBackgroundTimestamp && timestamp <= currentDidEnterBackgroundTimestamp }