Browse Source

Only add a home timezone if user added nothing!

pull/92/head
Abhishek 4 years ago
parent
commit
12d7684ec9
  1. 22
      Clocker/AppDelegate.swift
  2. 20
      Clocker/Onboarding/OnboardingParentViewController.swift

22
Clocker/AppDelegate.swift

@ -139,11 +139,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
// Install the menubar item! // Install the menubar item!
statusBarHandler = StatusItemHandler() statusBarHandler = StatusItemHandler()
if UserDefaults.standard.object(forKey: CLInstallHomeIndicatorObject) == nil {
fetchLocalTimezone()
UserDefaults.standard.set(1, forKey: CLInstallHomeIndicatorObject)
}
if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) { if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) {
RateController.setPreviewMode(true) RateController.setPreviewMode(true)
} }
@ -210,23 +205,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
alert.runModal() 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) { @IBAction func ping(_ sender: Any) {
togglePanel(sender) togglePanel(sender)
} }

20
Clocker/Onboarding/OnboardingParentViewController.swift

@ -2,6 +2,7 @@
import Cocoa import Cocoa
import CoreLoggerKit import CoreLoggerKit
import CoreModelKit
import StartupKit import StartupKit
extension NSStoryboard.SceneIdentifier { 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() { 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 { guard let fromViewController = onboardingSearchVC, let toViewController = finalOnboardingVC else {
assertionFailure() assertionFailure()
return return

Loading…
Cancel
Save