From 7ca7887ae82c09270869ed6737f94a99e210665c Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 18 Mar 2015 09:17:40 +0100 Subject: Finally use unter to update timer edition --- src/Update/Update.elm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/Update/Update.elm') diff --git a/src/Update/Update.elm b/src/Update/Update.elm index 4725970..8285760 100644 --- a/src/Update/Update.elm +++ b/src/Update/Update.elm @@ -27,6 +27,7 @@ type Action = | UpdateTimer Id TimerAction | RemoveTimer Id | EditTimer Id + | ValidTimerEdition | ReadOnly | KeyPressed KeyCode @@ -66,21 +67,19 @@ update action model = | timerEdition <- Just (newTimerEdition id) , timers <- Dict.update id (Maybe.map (updateTimer Pause)) model.timers } + ValidTimerEdition -> + case model.timerEdition of + Just timerEdition -> + { model + | timers <- Dict.update timerEdition.id (Maybe.map (updateTimer (SetTime (toTime timerEdition.numbers)))) model.timers + , timerEdition <- Nothing + } + Nothing -> + { model | timerEdition <- Nothing } ReadOnly -> { model | timerEdition <- Nothing } KeyPressed keyCode -> - if isEnter keyCode - then - case model.timerEdition of - Just timerEdition -> - { model - | timers <- Dict.update timerEdition.id (Maybe.map (updateTimer (SetTime (toTime timerEdition.numbers)))) model.timers - , timerEdition <- Nothing - } - Nothing -> - { model | timerEdition <- Nothing } - else - { model | timerEdition <- Maybe.map (updateTimerEdition (keyCodeToChar keyCode)) model.timerEdition } + { model | timerEdition <- Maybe.map (updateTimerEdition (keyCodeToChar keyCode)) model.timerEdition } isEnter : KeyCode -> Bool isEnter = (==) 107 -- cgit v1.2.3