diff options
author | Joris Guyonvarch | 2015-03-22 13:44:03 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-22 13:46:09 +0100 |
commit | a2b550b87a5f5bafa0d004606267838b135bcdb9 (patch) | |
tree | 1f48dd1290dba809c896d282033c3cb811e03a33 | |
parent | 7e442c937e1d0696c2cff591a06e869f92d08595 (diff) |
Validating time edition before updating timer with any action
-rw-r--r-- | src/Update/Update.elm | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Update/Update.elm b/src/Update/Update.elm index 5a4b12a..8fd5cb3 100644 --- a/src/Update/Update.elm +++ b/src/Update/Update.elm @@ -67,14 +67,13 @@ update action model = } UpdateTimer id action -> let maybeEdition = filterMaybe (\edition -> edition.id == id) model.edition - in case maybeEdition of - Just edition -> - { model - | timers <- Dict.update id (Maybe.map (updateTimer action)) model.timers - , edition <- Nothing - } - Nothing -> - { model | timers <- Dict.update id (Maybe.map (updateTimer action)) model.timers } + newModel = + case maybeEdition of + Just edition -> + if edition.kind == Time then validEdition model else model + Nothing -> + model + in { newModel | timers <- Dict.update id (Maybe.map (updateTimer action)) newModel.timers } RemoveTimer id -> if numberOfTimers model > 1 then |