Skip to content

Commit

Permalink
toggle mode after secondsLeft goes below 0
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjenningz committed Jul 10, 2017
1 parent 1243e7d commit 7f5e5d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## How to run

### Open in Ellie
1. Go to https://ellie-app.com/3J87ndy745ta1/0
1. Go to https://ellie-app.com/3Jb5cn87n8ta1/0
2. Click the compile button

### Build and run locally
Expand Down
11 changes: 6 additions & 5 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Mode

type alias Model =
{ secondsLeft : Int
, running : Bool
, clockRunning : Bool
, mode : Mode
, inputBox : String
, todos : List String
Expand Down Expand Up @@ -109,7 +109,7 @@ pomodoroTimer model =
[ text (clockTime model.secondsLeft) ]
, buttonGroup
[ resetButton
, playPauseButton model.running
, playPauseButton model.clockRunning
, nextButton
]
]
Expand Down Expand Up @@ -190,7 +190,8 @@ update msg model =
Tick time ->
if model.secondsLeft - 1 < 0 then
( { model
| secondsLeft = model.mode |> toggleMode |> modeToSeconds
| secondsLeft = toggleMode model.mode |> modeToSeconds
, mode = toggleMode model.mode
}
, makeSound ()
)
Expand All @@ -200,7 +201,7 @@ update msg model =
)

PlayPause ->
( { model | running = not model.running }, Cmd.none )
( { model | clockRunning = not model.clockRunning }, Cmd.none )

ToggleMode ->
let
Expand Down Expand Up @@ -271,7 +272,7 @@ port makeSound : () -> Cmd msg

subscriptions : Model -> Sub Msg
subscriptions model =
if model.running then
if model.clockRunning then
Time.every second Tick
else
Sub.none
Expand Down

0 comments on commit 7f5e5d4

Please sign in to comment.