diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/Main.elm | 19 | ||||
-rw-r--r-- | src/client/ServerCommunication.elm | 6 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/client/Main.elm b/src/client/Main.elm index c2ba408..e59692a 100644 --- a/src/client/Main.elm +++ b/src/client/Main.elm @@ -57,14 +57,17 @@ port initView = Just msg -> Signal.send actions.address (SignInError msg) Nothing -> - Task.andThen getUsers <| \users -> - Task.andThen whoAmI <| \me -> - Task.andThen getMonthlyPayments <| \monthlyPayments -> - Task.andThen getPayments <| \payments -> - Task.andThen getPaymentsCount <| \paymentsCount -> - Task.andThen getPayers <| \payers -> - Signal.send actions.address (GoLoggedInView users me monthlyPayments payments paymentsCount payers) - |> flip Task.onError (\_ -> Signal.send actions.address GoSignInView) + Task.onError goLoggedInView (\_ -> Signal.send actions.address GoSignInView) + +goLoggedInView : Task Http.Error () +goLoggedInView = + Task.andThen getUsers <| \users -> + Task.andThen whoAmI <| \me -> + Task.andThen getMonthlyPayments <| \monthlyPayments -> + Task.andThen getPayments <| \payments -> + Task.andThen getPaymentsCount <| \paymentsCount -> + Task.andThen getPayers <| \payers -> + Signal.send actions.address (GoLoggedInView users me monthlyPayments payments paymentsCount payers) getUsers : Task Http.Error Users getUsers = Http.get usersDecoder "/users" diff --git a/src/client/ServerCommunication.elm b/src/client/ServerCommunication.elm index 6d65552..fefbbff 100644 --- a/src/client/ServerCommunication.elm +++ b/src/client/ServerCommunication.elm @@ -76,8 +76,8 @@ simple method url = serverResult : Communication -> Http.Response -> Task Http.RawError U.Action serverResult communication response = - if response.status == 200 - then + case response.status of + 200 -> case communication of NoCommunication -> Task.succeed U.NoOp @@ -107,7 +107,7 @@ serverResult communication response = response SignOut -> Task.succeed (U.GoSignInView) - else + errorStatus -> decodeResponse messageDecoder (\error -> |