diff --git a/kDrive/AppDelegate+Launch.swift b/kDrive/AppDelegate+Launch.swift index 70005f013..7c96c48fb 100644 --- a/kDrive/AppDelegate+Launch.swift +++ b/kDrive/AppDelegate+Launch.swift @@ -27,12 +27,6 @@ import UIKit extension AppDelegate { // MARK: Launch - /// Refresh cache for `currentDrive`, Scan photo library and restart upload. - func refreshCacheAndRestartUpload() { - refreshCacheScanLibraryAndUpload(preload: false, isSwitching: false) - uploadEditedFiles() - } - func prepareRootViewController(currentState: RootViewControllerState) { switch currentState { case .appLock: diff --git a/kDrive/AppDelegate.swift b/kDrive/AppDelegate.swift index 0b026eb1e..b785a8887 100644 --- a/kDrive/AppDelegate.swift +++ b/kDrive/AppDelegate.swift @@ -80,8 +80,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDeleg window = UIWindow() setGlobalTint() - let currentState = RootViewControllerState.getCurrentState() - prepareRootViewController(currentState: currentState) + + let state = UIApplication.shared.applicationState + if state != .background { + appWillBePresentedToTheUser() + } accountManager.delegate = self @@ -119,12 +122,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDeleg } application.registerForRemoteNotifications() - let state = UIApplication.shared.applicationState - if state != .background { - // Remove all notifications on App Opening - UNUserNotificationCenter.current().removeAllDeliveredNotifications() - } - if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { shortcutItemToProcess = shortcutItem } @@ -227,7 +224,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDeleg func applicationWillEnterForeground(_ application: UIApplication) { Log.appDelegate("applicationWillEnterForeground") + appWillBePresentedToTheUser() + } + private func appWillBePresentedToTheUser() { @InjectService var uploadQueue: UploadQueue uploadQueue.pausedNotificationSent = false @@ -236,7 +236,8 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDeleg switch currentState { case .mainViewController, .appLock: UserDefaults.shared.numberOfConnections += 1 - refreshCacheAndRestartUpload() + refreshCacheScanLibraryAndUpload(preload: false, isSwitching: false) + uploadEditedFiles() case .onboarding: break // NOOP }