From 0cba27cba2b44756389d50bc113f23a2be87e978 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 3 Jan 2016 00:19:55 +0100 Subject: Prevent to send multiple payments if the server is not answering --- src/client/elm/Update.elm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/client/elm/Update.elm') diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm index 73dde9b..a33d47d 100644 --- a/src/client/elm/Update.elm +++ b/src/client/elm/Update.elm @@ -31,7 +31,7 @@ update action model = (model, Effects.none) SignIn assertion -> - ( applySignIn model (SignInAction.Connecting) + ( applySignIn model (SignInAction.WaitingServer) , sendRequest (Communication.SignIn assertion) |> flip Task.onError (\_ -> Task.succeed (UpdateSignIn (SignInAction.ErrorLogin (getMessage "ErrorSignIn" model.translations))) @@ -61,16 +61,23 @@ update action model = (applySignIn model signInAction, Effects.none) UpdateLoggedIn loggedInAction -> - (applyLoggedIn model loggedInAction, Effects.none) + applyLoggedIn model loggedInAction applySignIn : Model -> SignInAction -> Model applySignIn model signInAction = case model.view of - V.SignInView signInView -> { model | view = V.SignInView (updateSignIn signInAction signInView) } - _ -> model + V.SignInView signInView -> + { model | view = V.SignInView (updateSignIn signInAction signInView) } + _ -> + model -applyLoggedIn : Model -> LoggedInAction -> Model +applyLoggedIn : Model -> LoggedInAction -> (Model, Effects Action) applyLoggedIn model loggedInAction = case model.view of - V.LoggedInView loggedInView -> { model | view = V.LoggedInView (updateLoggedIn model loggedInAction loggedInView) } - _ -> model + V.LoggedInView loggedInView -> + let (loggedInView, effects) = updateLoggedIn model loggedInAction loggedInView + in ( { model | view = V.LoggedInView loggedInView } + , effects + ) + _ -> + (model, Effects.none) -- cgit v1.2.3