Skip to content

Commit

Permalink
Move splay and splay loop type to actually delay sofa
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 18, 2024
1 parent 9539d24 commit 1ff87be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Nudge/UI/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Globals {
static let nudgeJSONPreferences = NetworkFileManager().getNudgeJSONPreferences()
// Device Properties
static let gdmfAssets = NetworkFileManager().getGDMFAssets()
static let sofaAssets = NetworkFileManager().getSOFAAssets()
static var sofaAssets: MacOSDataFeed?
static let hardwareModelIDs = DeviceManager().getHardwareModelIDs()
}

Expand Down
11 changes: 9 additions & 2 deletions Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if OptionalFeatureVariables.utilizeSOFAFeed {
var selectedOS: OSInformation?
var foundMatch = false
Globals.sofaAssets = NetworkFileManager().getSOFAAssets()
if let macOSSOFAAssets = Globals.sofaAssets?.osVersions {
for osVersion in macOSSOFAAssets {
if PrefsWrapper.requiredMinimumOSVersion == "latest" {
Expand Down Expand Up @@ -281,10 +282,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
handleSMAppService()
checkForBadProfilePath()
handleCommandLineArguments()
applyRandomDelayIfNecessary()
applyGracePeriodLogic()
sofaPreLaunchLogic()
applydelayNudgeEventLogic()
applyRandomDelayIfNecessary()
updateNudgeState()
handleSoftwareUpdateRequirements()
}
Expand Down Expand Up @@ -355,7 +356,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if UserExperienceVariables.randomDelay && !CommandLine.arguments.contains("-disable-randomDelay") {
let delaySeconds = Int.random(in: 1...UserExperienceVariables.maxRandomDelayInSeconds)
LogManager.notice("Delaying initial run (in seconds) by: \(delaySeconds)", logger: uiLog)
sleep(UInt32(delaySeconds))

let delayDate = Date().addingTimeInterval(TimeInterval(delaySeconds))
while Date() < delayDate {
RunLoop.current.run(mode: .default, before: delayDate)
}

LogManager.notice("Finished delay", logger: uiLog)
}
}

Expand Down

0 comments on commit 1ff87be

Please sign in to comment.