From 302a2e798f10e61c129753a2bd11634420c1f1a1 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 2 Jan 2016 20:31:25 +0100 Subject: Set a spinner for sign in --- src/client/elm/Update.elm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/client/elm/Update.elm') diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm index c955f8c..c61e2f5 100644 --- a/src/client/elm/Update.elm +++ b/src/client/elm/Update.elm @@ -9,15 +9,20 @@ import Effects exposing (Effects) import ServerCommunication exposing (sendRequest) import Model exposing (Model) +import Model.Translations exposing (getMessage) import Model.Action exposing (..) +import Model.Action.SignInAction as SignInAction import Model.View as V import Model.View.SignInView exposing (..) import Model.View.LoggedInView exposing (..) -import Model.Communication exposing (Communication) +import Model.Communication as Communication exposing (Communication) import Update.LoggedIn exposing (updateLoggedIn) import Update.SignIn exposing (updateSignIn) +import SimpleHTTP exposing (post) +import InitViewAction exposing (initViewAction) + update : Action -> Model -> (Model, Effects Action) update action model = case action of @@ -25,6 +30,15 @@ update action model = NoOp -> (model, Effects.none) + SignIn assertion -> + ( case model.view of + V.SignInView signInView -> { model | view = V.SignInView (updateSignIn SignInAction.Connecting signInView) } + _ -> model + , sendRequest (Communication.SignIn assertion) + |> flip Task.onError (always <| Task.succeed (UpdateSignIn (SignInAction.ErrorLogin (getMessage "ErrorSignIn" model.translations)))) + |> Effects.task + ) + ServerCommunication communication -> ( model , sendRequest communication -- cgit v1.2.3