From 9104fac638cb45ccdfc28002bf84335dea37e83f Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Sat, 17 Jan 2026 16:36:46 +0100 Subject: [PATCH] Remove the remoteControlledLights helper value --- NightLight.Core.Tests/LightArbitraries.fs | 9 ++++++--- NightLight.Core/Models.fs | 3 --- NightLight.Core/NightLightStateMachine.fs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/NightLight.Core.Tests/LightArbitraries.fs b/NightLight.Core.Tests/LightArbitraries.fs index d1de91a..2f7d2b4 100644 --- a/NightLight.Core.Tests/LightArbitraries.fs +++ b/NightLight.Core.Tests/LightArbitraries.fs @@ -15,18 +15,21 @@ type ArbitraryNonRemotelyControlledLight = type ArbitraryLeftRemotelyControlledLight = static member Light() = - remoteControlledLights + lights |> Seq.filter _.ControlledWithRemote.IsRemoteLeft |> Gen.elements |> Arb.fromGen type ArbitraryRightRemotelyControlledLight = static member Light() = - remoteControlledLights + lights |> Seq.filter _.ControlledWithRemote.IsRemoteRight |> Gen.elements |> Arb.fromGen type ArbitraryRemotelyControlledLight = static member Light() = - remoteControlledLights |> Gen.elements |> Arb.fromGen + lights + |> Seq.filter (not << _.ControlledWithRemote.IsNonRemote) + |> Gen.elements + |> Arb.fromGen diff --git a/NightLight.Core/Models.fs b/NightLight.Core/Models.fs index 719e4f7..10fe7f8 100644 --- a/NightLight.Core/Models.fs +++ b/NightLight.Core/Models.fs @@ -73,9 +73,6 @@ let lights = Bulb = IkeaBulb ControlledWithRemote = RemoteLeft } ] -let remoteControlledLights = - lights |> Seq.filter (not << _.ControlledWithRemote.IsNonRemote) - let remoteControlFriendlyName = DeviceFriendlyName "FjÀrrkontroll" type internal State = diff --git a/NightLight.Core/NightLightStateMachine.fs b/NightLight.Core/NightLightStateMachine.fs index 8730f29..57b535b 100644 --- a/NightLight.Core/NightLightStateMachine.fs +++ b/NightLight.Core/NightLightStateMachine.fs @@ -37,7 +37,8 @@ let internal withStateFor (light: Light) (state: State) (oldNightLightState: Nig LightToState = Map.add light { oldState with State = state } oldNightLightState.LightToState } let internal withStateForRemoteControlledLights (state: State) (oldNightLightState: NightLightState) = - remoteControlledLights + lights + |> Seq.filter (not << _.ControlledWithRemote.IsNonRemote) |> Seq.fold (fun acc light -> acc |> withStateFor light state) oldNightLightState let internal withAlarmOff (oldNightLightState: NightLightState) = @@ -79,8 +80,7 @@ type NightLightStateMachine private (maybeState: NightLightState option) = | PressedOff -> currentState |> withStateForRemoteControlledLights Off | PressedLeft -> let lightThatShouldBeOn = - remoteControlledLights - |> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft) + lights |> Seq.find (fun light -> light.ControlledWithRemote = RemoteLeft) currentState |> withStateForRemoteControlledLights Off