From 0e1848afb265470d75aa78289d81a9210e795524 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Wed, 20 Apr 2022 12:50:14 -0400 Subject: [PATCH] Fix premature optimization. --- Clocker/AppDelegate.swift | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Clocker/AppDelegate.swift b/Clocker/AppDelegate.swift index a2b2a0d..2f3a1cd 100644 --- a/Clocker/AppDelegate.swift +++ b/Clocker/AppDelegate.swift @@ -88,16 +88,20 @@ open class AppDelegate: NSObject, NSApplicationDelegate { NSApp.setActivationPolicy(.accessory) } - private lazy var controller: OnboardingController? = { - let onboardingStoryboard = NSStoryboard(name: NSStoryboard.Name("Onboarding"), bundle: nil) - return onboardingStoryboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier("onboardingFlow")) as? OnboardingController - }() - + private var controller: OnboardingController? + private func showOnboardingFlowIfEligible() { - let shouldLaunchOnboarding = (DataStore.shared().retrieve(key: CLShowOnboardingFlow) == nil && DataStore.shared().timezones().isEmpty) - || ProcessInfo.processInfo.arguments.contains(CLOnboaringTestsLaunchArgument) - - shouldLaunchOnboarding ? controller?.launch() : continueUsually() + let shouldLaunchOnboarding = (DataStore.shared().retrieve(key: CLShowOnboardingFlow) == nil + && DataStore.shared().timezones().isEmpty) + || ProcessInfo.processInfo.arguments.contains(CLOnboaringTestsLaunchArgument) + + if (shouldLaunchOnboarding) { + let onboardingStoryboard = NSStoryboard(name: NSStoryboard.Name("Onboarding"), bundle: nil) + controller = onboardingStoryboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier("onboardingFlow")) as? OnboardingController + controller?.launch() + } else { + continueUsually() + } } func continueUsually() {