From 12d7684ec925f4269e3c7515e2af1f176092b747 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 6 Feb 2021 18:00:36 -0600 Subject: [PATCH] Only add a home timezone if user added nothing! --- Clocker/AppDelegate.swift | 22 ------------------- .../OnboardingParentViewController.swift | 20 +++++++++++++++++ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Clocker/AppDelegate.swift b/Clocker/AppDelegate.swift index 806752a..5a850ae 100644 --- a/Clocker/AppDelegate.swift +++ b/Clocker/AppDelegate.swift @@ -139,11 +139,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate { // Install the menubar item! statusBarHandler = StatusItemHandler() - if UserDefaults.standard.object(forKey: CLInstallHomeIndicatorObject) == nil { - fetchLocalTimezone() - UserDefaults.standard.set(1, forKey: CLInstallHomeIndicatorObject) - } - if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) { RateController.setPreviewMode(true) } @@ -210,23 +205,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate { alert.runModal() } - private func fetchLocalTimezone() { - let identifier = TimeZone.autoupdatingCurrent.identifier - - let currentTimezone = TimezoneData() - currentTimezone.timezoneID = identifier - currentTimezone.setLabel(identifier) - currentTimezone.formattedAddress = identifier - currentTimezone.isSystemTimezone = true - currentTimezone.placeID = "Home" - - let operations = TimezoneDataOperations(with: currentTimezone) - operations.saveObject(at: 0) - - // Retrieve Location - // retrieveLatestLocation() - } - @IBAction func ping(_ sender: Any) { togglePanel(sender) } diff --git a/Clocker/Onboarding/OnboardingParentViewController.swift b/Clocker/Onboarding/OnboardingParentViewController.swift index 105f269..73e557c 100644 --- a/Clocker/Onboarding/OnboardingParentViewController.swift +++ b/Clocker/Onboarding/OnboardingParentViewController.swift @@ -2,6 +2,7 @@ import Cocoa import CoreLoggerKit +import CoreModelKit import StartupKit extension NSStoryboard.SceneIdentifier { @@ -178,7 +179,26 @@ class OnboardingParentViewController: NSViewController { } } + private func fetchLocalTimezone() { + let identifier = TimeZone.autoupdatingCurrent.identifier + + let currentTimezone = TimezoneData() + currentTimezone.timezoneID = identifier + currentTimezone.setLabel(identifier) + currentTimezone.formattedAddress = identifier + currentTimezone.isSystemTimezone = true + currentTimezone.placeID = "Home" + + let operations = TimezoneDataOperations(with: currentTimezone) + operations.saveObject(at: 0) + } + private func navigateToFinalStage() { + if UserDefaults.standard.object(forKey: CLInstallHomeIndicatorObject) == nil, DataStore.shared().timezones().isEmpty { + fetchLocalTimezone() + UserDefaults.standard.set(1, forKey: CLInstallHomeIndicatorObject) + } + guard let fromViewController = onboardingSearchVC, let toViewController = finalOnboardingVC else { assertionFailure() return