Skip to content

Commit

Permalink
fix scheduled state calculation on custom time and set dark mode on s…
Browse files Browse the repository at this point in the history
…creen wake
  • Loading branch information
thompsonate committed Sep 30, 2018
1 parent 693ad9f commit 3ebc55b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Shifty/NightShiftManager.swift
Expand Up @@ -179,10 +179,14 @@ enum NightShiftManager {
let now = Time(Date())
if endTime > startTime {
//startTime and endTime are on the same day
return now >= startTime && now <= endTime
let scheduledState = now >= startTime && now < endTime
logw("scheduled state: \(scheduledState)")
return scheduledState
} else {
//endTime is on the day following startTime
return now >= startTime || now <= endTime
let scheduledState = now >= startTime || now < endTime
logw("scheduled state: \(scheduledState)")
return scheduledState
}
case .solar:
guard let sunrise = BrightnessSystemClient.shared?.sunrise,
Expand Down Expand Up @@ -257,9 +261,12 @@ enum NightShiftManager {

NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: nil) { _ in
logw("Wake from sleep notification posted")

if scheduledState != isNightShiftEnabled {
respond(to: scheduledState ? .enteredScheduledNightShift : .exitedScheduledNightShift)
}

updateDarkMode()
}
}

Expand Down

0 comments on commit 3ebc55b

Please sign in to comment.