diff options
Diffstat (limited to 'src/Update/UpdateTimer.elm')
-rw-r--r-- | src/Update/UpdateTimer.elm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Update/UpdateTimer.elm b/src/Update/UpdateTimer.elm index e4671d9..c147d23 100644 --- a/src/Update/UpdateTimer.elm +++ b/src/Update/UpdateTimer.elm @@ -6,6 +6,7 @@ module Update.UpdateTimer import Time (Time) import Model.Timer (..) +import Model.TimerState (..) import Model.Id (..) type TimerAction = @@ -20,19 +21,22 @@ updateTimer action timer = case action of Restart -> { timer - | isRunning <- True - , currentTime <- initTime timer.initialTime + | currentTime <- initTime timer.initialTime + , state <- Running } Pause -> + { timer | state <- Idle } + ToggleRunning -> { timer - | isRunning <- False + | state <- + if timer.currentTime > 0 && timer.state == Idle + then Running + else Idle } - ToggleRunning -> - { timer | isRunning <- timer.currentTime > 0.0 && not timer.isRunning } Stop -> { timer - | isRunning <- False - , currentTime <- initTime timer.initialTime + | currentTime <- initTime timer.initialTime + , state <- Idle } SetTime time -> let augmentedTime = time + 999 |