From 869bab77e93e2a6c776a4b1fc35ef0fd5df22f5f Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Mar 2016 17:36:33 +0200 Subject: Compute payers client side rather than server side --- src/client/elm/Update/LoggedIn/Account.elm | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/client/elm/Update/LoggedIn/Account.elm') diff --git a/src/client/elm/Update/LoggedIn/Account.elm b/src/client/elm/Update/LoggedIn/Account.elm index 1773b9a..233efa9 100644 --- a/src/client/elm/Update/LoggedIn/Account.elm +++ b/src/client/elm/Update/LoggedIn/Account.elm @@ -10,7 +10,6 @@ import Effects exposing (Effects) import Server -import Model.Payer exposing (updatePayers) import Model.Action.AccountAction exposing (..) import Model.View.LoggedIn.Account exposing (..) @@ -28,11 +27,6 @@ updateAccount action account = , Effects.none ) - UpdatePayer userId creation amountDiff -> - ( { account | payers = updatePayers account.payers userId creation amountDiff } - , Effects.none - ) - ToggleIncomeEdition -> ( { account | incomeEdition = if isJust account.incomeEdition @@ -67,25 +61,14 @@ updateAccount action account = UpdateIncome currentTime amount -> ( account , Server.setIncome currentTime amount - |> Task.map (always (ValidateUpdateIncome currentTime amount)) + |> Task.map (\incomeId -> (ValidateUpdateIncome incomeId currentTime amount)) |> flip Task.onError (always <| Task.succeed NoOp) |> Effects.task ) - ValidateUpdateIncome currentTime amount -> + ValidateUpdateIncome incomeId currentTime amount -> ( { account - | payers = - account.payers - |> Dict.update account.me (\mbPayer -> - case mbPayer of - Just payer -> - Just - { payer - | incomes = payer.incomes ++ [{ creation = currentTime, amount = amount }] - } - Nothing -> - Nothing - ) + | incomes = Dict.insert incomeId { userId = account.me, creation = currentTime, amount = amount } account.incomes , incomeEdition = Nothing } , Effects.none -- cgit v1.2.3