diff --git a/kDrive/AppDelegate.swift b/kDrive/AppDelegate.swift index 66cfcb463..a34cd0b12 100644 --- a/kDrive/AppDelegate.swift +++ b/kDrive/AppDelegate.swift @@ -36,7 +36,7 @@ import VersionChecker @main final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate { /// Making sure the DI is registered at a very early stage of the app launch. - private let dependencyInjectionHook = EarlyDIHook() + private let dependencyInjectionHook = EarlyDIHook(context: .app) private var reachabilityListener: ReachabilityListener! private static let currentStateVersion = 4 diff --git a/kDrive/Utils/AppFactoryService.swift b/kDrive/Utils/AppFactoryService.swift index 5b63f7ac8..c922a8992 100644 --- a/kDrive/Utils/AppFactoryService.swift +++ b/kDrive/Utils/AppFactoryService.swift @@ -21,15 +21,24 @@ import InfomaniakDI import kDriveCore import os.log +public enum AppContext { + case app + case actionExtension + case fileProviderExtension + case shareExtension +} + /// Something that loads the DI on init public struct EarlyDIHook { - public init() { + public init(context: AppContext) { // setup DI ASAP let navigationManagerFactory = Factory(type: NavigationManageable.self) { _, _ in NavigationManager() } + // TODO: Insert context in dedicated DI object + os_log("EarlyDIHook") FactoryService.setupDependencyInjection(other: [navigationManagerFactory]) } diff --git a/kDriveActionExtension/ActionNavigationController.swift b/kDriveActionExtension/ActionNavigationController.swift index 0ba42d23a..0cd4090d1 100644 --- a/kDriveActionExtension/ActionNavigationController.swift +++ b/kDriveActionExtension/ActionNavigationController.swift @@ -25,7 +25,7 @@ import VersionChecker final class ActionNavigationController: TitleSizeAdjustingNavigationController { /// Making sure the DI is registered at a very early stage of the app launch. - private let dependencyInjectionHook = EarlyDIHook() + private let dependencyInjectionHook = EarlyDIHook(context: .actionExtension) @LazyInjectService var accountManager: AccountManageable diff --git a/kDriveFileProvider/FileProviderExtension.swift b/kDriveFileProvider/FileProviderExtension.swift index f491fef25..145d17f86 100644 --- a/kDriveFileProvider/FileProviderExtension.swift +++ b/kDriveFileProvider/FileProviderExtension.swift @@ -26,7 +26,7 @@ import RealmSwift final class FileProviderExtension: NSFileProviderExtension { /// Making sure the DI is registered at a very early stage of the app launch. - private let dependencyInjectionHook = EarlyDIHook() + private let dependencyInjectionHook = EarlyDIHook(context: .fileProviderExtension) /// Something to enqueue async await tasks in a serial manner. let asyncAwaitQueue = TaskQueue() diff --git a/kDriveShareExtension/ShareNavigationViewController.swift b/kDriveShareExtension/ShareNavigationViewController.swift index faa3a7483..2c955d31f 100644 --- a/kDriveShareExtension/ShareNavigationViewController.swift +++ b/kDriveShareExtension/ShareNavigationViewController.swift @@ -25,7 +25,7 @@ import VersionChecker final class ShareNavigationViewController: TitleSizeAdjustingNavigationController { /// Making sure the DI is registered at a very early stage of the app launch. - private let dependencyInjectionHook = EarlyDIHook() + private let dependencyInjectionHook = EarlyDIHook(context: .shareExtension) @LazyInjectService var accountManager: AccountManageable