Get rid of partOfDayChanged
This commit is contained in:
parent
bc421bc1a7
commit
b55e48ab22
1 changed files with 3 additions and 7 deletions
|
|
@ -84,11 +84,11 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
||||||
| TimeChanged newTime, maybeCurrentState ->
|
| TimeChanged newTime, maybeCurrentState ->
|
||||||
let newPartOfDay = getPartOfDay newTime
|
let newPartOfDay = getPartOfDay newTime
|
||||||
|
|
||||||
let partOfDayChanged =
|
let newDayStarted =
|
||||||
let maybePreviousPartOfDay =
|
let maybePreviousPartOfDay =
|
||||||
maybeCurrentState |> Option.map _.Time |> Option.map getPartOfDay
|
maybeCurrentState |> Option.map _.Time |> Option.map getPartOfDay
|
||||||
|
|
||||||
maybePreviousPartOfDay <> Some newPartOfDay
|
maybePreviousPartOfDay <> Some Day && newPartOfDay = Day
|
||||||
|
|
||||||
let newLightToState =
|
let newLightToState =
|
||||||
lights
|
lights
|
||||||
|
|
@ -102,11 +102,7 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
||||||
|> Option.map _.LightToState[light].State
|
|> Option.map _.LightToState[light].State
|
||||||
|> Option.defaultValue On
|
|> Option.defaultValue On
|
||||||
|
|
||||||
let newState =
|
let newState = if newDayStarted then On else previousState
|
||||||
if partOfDayChanged && newPartOfDay = Day then
|
|
||||||
On
|
|
||||||
else
|
|
||||||
previousState
|
|
||||||
|
|
||||||
light,
|
light,
|
||||||
{ Color = color
|
{ Color = color
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue