Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit c3ae384

Browse files
authored
Refactor AppDelegate (milestone 1) (#3727)
Task/Issue URL: https://app.asana.com/0/0/1208832732122403/f Tech Design URL: https://app.asana.com/0/481882893211075/1208859623176995/f CC: @bwaresiak **Description**: - Migrate the app’s startup flow into a state machine with clearly defined states, each specifying its dependencies to ensure the necessary resources are available before execution. - Keep the flow primarily synchronous as it currently is, with some exceptions for existing async code. - Define explicit state dependencies to avoid optional objects, ensuring clarity about what exists in each state.
1 parent 42228ca commit c3ae384

27 files changed

Lines changed: 3164 additions & 1354 deletions

‎Core/Pixel.swift‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,6 @@ public struct PixelParameters {
165165

166166
public static let appState = "state"
167167
public static let appEvent = "event"
168-
169-
public static let firstBackgroundTimestamp = "firstBackgroundTimestamp"
170-
public static let secondBackgroundTimestamp = "secondBackgroundTimestamp"
171-
public static let didReceiveMemoryWarningTimestamp = "didReceiveMemoryWarningTimestamp"
172-
public static let didReceiveMXPayloadTimestamp = "didReceiveMXPayloadTimestamp"
173-
public static let didReceiveUNNotification = "didReceiveUNNotification"
174-
public static let didStartRemoteMessagingClientBackgroundTask = "didStartRemoteMessagingClientBackgroundTask"
175-
public static let didStartAppConfigurationFetchBackgroundTask = "didStartAppConfigurationFetchBackgroundTask"
176-
public static let didPerformFetchTimestamp = "didPerformFetchTimestamp"
177-
public static let numberOfBackgrounds = "numberOfBackgrounds"
178168
}
179169

180170
public struct PixelValues {

‎Core/PixelEvent.swift‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ extension Pixel {
971971

972972
// MARK: Lifecycle
973973
case appDidTransitionToUnexpectedState
974-
case appDidConsecutivelyBackground
975974
}
976975

977976
}
@@ -1939,8 +1938,7 @@ extension Pixel.Event {
19391938
case .openAIChatFromAddressBar: return "m_aichat_addressbar_icon"
19401939

19411940
// MARK: Lifecycle
1942-
case .appDidTransitionToUnexpectedState: return "m_debug_app-did-transition-to-unexpected-state"
1943-
case .appDidConsecutivelyBackground: return "m_debug_app-did-consecutively-background"
1941+
case .appDidTransitionToUnexpectedState: return "m_debug_app-did-transition-to-unexpected-state-2"
19441942

19451943
}
19461944
}

‎DuckDuckGo.xcodeproj/project.pbxproj‎

Lines changed: 54 additions & 18 deletions
Large diffs are not rendered by default.

‎DuckDuckGo/AppConfigurationFetch.swift‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ class AppConfigurationFetch {
8585
return Date().timeIntervalSince(Self.lastConfigurationRefreshDate) > Constants.minimumConfigurationRefreshInterval
8686
}
8787

88-
static var didStartBackgroundTaskTimestamp: Date?
89-
9088
enum BackgroundRefreshCompletionStatus {
9189

9290
case expired
@@ -134,7 +132,6 @@ class AppConfigurationFetch {
134132

135133
static func registerBackgroundRefreshTaskHandler() {
136134
BGTaskScheduler.shared.register(forTaskWithIdentifier: Constants.backgroundProcessingTaskIdentifier, using: nil) { (task) in
137-
didStartBackgroundTaskTimestamp = Date()
138135
guard shouldRefresh else {
139136
task.setTaskCompleted(success: true)
140137
scheduleBackgroundRefreshTask()

‎DuckDuckGo/AppDelegate+AppDeepLinks.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import UIKit
2121
import Core
2222

23-
extension AppDelegate {
23+
extension OldAppDelegate {
2424

2525
func handleAppDeepLink(_ app: UIApplication, _ mainViewController: MainViewController?, _ url: URL) -> Bool {
2626
guard let mainViewController else { return false }

0 commit comments

Comments
 (0)