From d87dbd1360c14df83552fd757438c23e5d7b9f9c Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 11 Sep 2015 10:36:27 +0200 Subject: Using jsonObject to create on the fly json object responses --- src/client/Main.elm | 1 - src/client/Model/Message.elm | 8 -------- src/client/ServerCommunication.elm | 19 +++++++++---------- 3 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 src/client/Model/Message.elm (limited to 'src/client') diff --git a/src/client/Main.elm b/src/client/Main.elm index e59692a..0b579d7 100644 --- a/src/client/Main.elm +++ b/src/client/Main.elm @@ -15,7 +15,6 @@ import Model exposing (Model, initialModel) import Model.User exposing (Users, usersDecoder, UserId, userIdDecoder) import Model.Payment exposing (Payments, paymentsDecoder, perPage) import Model.Payers exposing (Payers, payersDecoder) -import Model.Message exposing (messageDecoder) import Model.Translations exposing (..) import Update exposing (Action(..), actions, updateModel) diff --git a/src/client/Model/Message.elm b/src/client/Model/Message.elm deleted file mode 100644 index 9f21fd3..0000000 --- a/src/client/Model/Message.elm +++ /dev/null @@ -1,8 +0,0 @@ -module Model.Message - ( messageDecoder - ) where - -import Json.Decode exposing (..) - -messageDecoder : Decoder String -messageDecoder = ("message" := string) diff --git a/src/client/ServerCommunication.elm b/src/client/ServerCommunication.elm index fefbbff..5736f77 100644 --- a/src/client/ServerCommunication.elm +++ b/src/client/ServerCommunication.elm @@ -10,7 +10,6 @@ import Http import Json.Decode exposing (..) import Date -import Model.Message exposing (messageDecoder) import Model.User exposing (UserId) import Model.Payment exposing (..) import Model.View.LoggedIn.Add exposing (Frequency(..)) @@ -108,16 +107,16 @@ serverResult communication response = SignOut -> Task.succeed (U.GoSignInView) errorStatus -> - decodeResponse - messageDecoder - (\error -> - case communication of - SignIn _ -> + case communication of + SignIn _ -> + decodeResponse + ("error" := string) + (\error -> Task.succeed <| U.UpdateSignIn (ErrorLogin error) - _ -> - Task.succeed <| U.NoOp - ) - response + ) + response + _ -> + Task.succeed <| U.NoOp decodeOkResponse : Decoder a -> (a -> Task b U.Action) -> Http.Response -> Task b U.Action decodeOkResponse decoder responseToAction response = -- cgit v1.2.3