blob: e45a3c238fa3cec0f0b84c31cae8b592b31b03e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
module Update.UpdateTimer
( TimerAction(..)
, updateTimer
) where
import Time (Time)
import Model.Timer (..)
import Model.TimerState (..)
import Model.Id (..)
type TimerAction =
Pause
| ToggleRunning
| Stop
| SetTime Time
updateTimer : TimerAction -> Timer -> Timer
updateTimer action timer =
case action of
Pause ->
{ timer | state <- Idle }
ToggleRunning ->
{ timer
| state <-
if timer.currentTime > 0 && timer.state == Idle
then Running
else Idle
}
Stop ->
{ timer
| currentTime <- initTime timer.initialTime
, state <- Idle
}
SetTime time ->
let augmentedTime = time + 999
in { timer
| initialTime <- time
, currentTime <- augmentedTime
}
|