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

Refactor AppDelegate (milestone 1) #3727

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
85d82b5
Move willResignActive code into Inactive state
jaceklyp Dec 3, 2024
ed3a56c
Move app shortcuts code into extension
jaceklyp Dec 3, 2024
cdff905
Move app shortcuts code into extension
jaceklyp Dec 3, 2024
75e8004
Make states api cleaner
jaceklyp Dec 4, 2024
e4f9be0
Clean more dependency hell
jaceklyp Dec 5, 2024
85c6416
Runnable state
jaceklyp Dec 9, 2024
dfd1e96
Testing
jaceklyp Dec 10, 2024
46621eb
Refactor the code not to use functions on self
jaceklyp Dec 10, 2024
b64e651
Add code to Launch that has been added on main the meantime
jaceklyp Dec 11, 2024
8e69357
Fix subscription code
jaceklyp Dec 11, 2024
33e7bde
Fix sync cancellable
jaceklyp Dec 11, 2024
3a4f7e1
Merge branch 'main' into jacek/refactor-app-delegate-m1
jaceklyp Dec 11, 2024
ac486b4
Make it buildable after merge
jaceklyp Dec 11, 2024
017d655
Make appdelegate work in dual mode and handle shortcuts
jaceklyp Dec 12, 2024
128f049
Add autoclear code to handleShortcutItem
jaceklyp Dec 13, 2024
7fee87d
Add comment
jaceklyp Dec 13, 2024
d6edc0b
Handle new cases in state machine
jaceklyp Dec 13, 2024
d6ed3de
Fix swiftlint
jaceklyp Dec 13, 2024
0174398
Fix compilation issue
jaceklyp Dec 13, 2024
f19431b
Fix tests
jaceklyp Dec 13, 2024
5e901f8
Fix tests
jaceklyp Dec 16, 2024
29564d2
Divide code into old and new app delegates
jaceklyp Dec 16, 2024
c11ea21
Fix syncCancellable not being reassigned
jaceklyp Dec 17, 2024
e5af352
Fix running shorcuts when app is backgrounded
jaceklyp Dec 17, 2024
8cca2ce
Introduce a kill switch for the new feature
jaceklyp Dec 18, 2024
b22ce95
Fix issues
jaceklyp Dec 18, 2024
0e0412d
Add testing state
jaceklyp Dec 18, 2024
785e6da
Fix leftover comments
jaceklyp Dec 18, 2024
af9e049
Merge branch 'main' into jacek/refactor-app-delegate-m1
jaceklyp Dec 18, 2024
504729c
Update BSK ref
jaceklyp Dec 19, 2024
ea30ce0
Apply changes to appDelegate from the main
jaceklyp Dec 20, 2024
ff80734
Merge branch 'main' into jacek/refactor-app-delegate-m1
jaceklyp Dec 20, 2024
d5663f3
Merge branch 'main' into jacek/refactor-app-delegate-m1
jaceklyp Dec 20, 2024
f733e5b
Remove unused pixel
jaceklyp Dec 20, 2024
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
10 changes: 0 additions & 10 deletions Core/Pixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@

public static let appState = "state"
public static let appEvent = "event"

public static let firstBackgroundTimestamp = "firstBackgroundTimestamp"
public static let secondBackgroundTimestamp = "secondBackgroundTimestamp"
public static let didReceiveMemoryWarningTimestamp = "didReceiveMemoryWarningTimestamp"
public static let didReceiveMXPayloadTimestamp = "didReceiveMXPayloadTimestamp"
public static let didReceiveUNNotification = "didReceiveUNNotification"
public static let didStartRemoteMessagingClientBackgroundTask = "didStartRemoteMessagingClientBackgroundTask"
public static let didStartAppConfigurationFetchBackgroundTask = "didStartAppConfigurationFetchBackgroundTask"
public static let didPerformFetchTimestamp = "didPerformFetchTimestamp"
public static let numberOfBackgrounds = "numberOfBackgrounds"
}

public struct PixelValues {
Expand Down Expand Up @@ -282,7 +272,7 @@
allowedQueryReservedCharacters: allowedQueryReservedCharacters,
headers: headers)
let request = APIRequest(configuration: configuration, urlSession: .session(useMainThreadCallbackQueue: true))
request.fetch { _, error in

Check warning on line 275 in Core/Pixel.swift

View workflow job for this annotation

GitHub Actions / Unit Tests

'fetch(completion:)' is deprecated: Please use 'APIService' instead.

Check warning on line 275 in Core/Pixel.swift

View workflow job for this annotation

GitHub Actions / Make Release Build

'fetch(completion:)' is deprecated: Please use 'APIService' instead.

Check warning on line 275 in Core/Pixel.swift

View workflow job for this annotation

GitHub Actions / Make Release Build

'fetch(completion:)' is deprecated: Please use 'APIService' instead.
Logger.general.debug("Pixel fired \(pixelName, privacy: .public) \(params, privacy: .public)")
onComplete(error)
}
Expand Down
4 changes: 1 addition & 3 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@ extension Pixel {

// MARK: Lifecycle
case appDidTransitionToUnexpectedState
case appDidConsecutivelyBackground
}

}
Expand Down Expand Up @@ -1891,8 +1890,7 @@ extension Pixel.Event {
case .openAIChatFromAddressBar: return "m_aichat_addressbar_icon"

// MARK: Lifecycle
case .appDidTransitionToUnexpectedState: return "m_debug_app-did-transition-to-unexpected-state"
case .appDidConsecutivelyBackground: return "m_debug_app-did-consecutively-background"
case .appDidTransitionToUnexpectedState: return "m_debug_app-did-transition-to-unexpected-state-2"

}
}
Expand Down
72 changes: 54 additions & 18 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions DuckDuckGo/AppConfigurationFetch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class AppConfigurationFetch {
return Date().timeIntervalSince(Self.lastConfigurationRefreshDate) > Constants.minimumConfigurationRefreshInterval
}

static var didStartBackgroundTaskTimestamp: Date?

enum BackgroundRefreshCompletionStatus {

case expired
Expand Down Expand Up @@ -134,7 +132,6 @@ class AppConfigurationFetch {

static func registerBackgroundRefreshTaskHandler() {
BGTaskScheduler.shared.register(forTaskWithIdentifier: Constants.backgroundProcessingTaskIdentifier, using: nil) { (task) in
didStartBackgroundTaskTimestamp = Date()
guard shouldRefresh else {
task.setTaskCompleted(success: true)
scheduleBackgroundRefreshTask()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AppDelegate+AppDeepLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import UIKit
import Core

extension AppDelegate {
extension OldAppDelegate {

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