aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Update.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Update.elm')
-rw-r--r--src/client/elm/Update.elm28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/client/elm/Update.elm b/src/client/elm/Update.elm
index a33d47d..b473c9d 100644
--- a/src/client/elm/Update.elm
+++ b/src/client/elm/Update.elm
@@ -6,7 +6,7 @@ import Task
import Effects exposing (Effects)
-import ServerCommunication exposing (sendRequest)
+import Server
import Model exposing (Model)
import Model.Translations exposing (getMessage)
@@ -16,7 +16,6 @@ import Model.Action.LoggedInAction exposing (LoggedInAction)
import Model.View as V
import Model.View.SignInView exposing (..)
import Model.View.LoggedInView exposing (..)
-import Model.Communication as Communication exposing (Communication)
import Update.LoggedIn exposing (updateLoggedIn)
import Update.SignIn exposing (updateSignIn)
@@ -32,25 +31,25 @@ update action model =
SignIn assertion ->
( applySignIn model (SignInAction.WaitingServer)
- , sendRequest (Communication.SignIn assertion)
+ , Server.signIn assertion
|> flip Task.onError (\_ ->
Task.succeed (UpdateSignIn (SignInAction.ErrorLogin (getMessage "ErrorSignIn" model.translations)))
)
|> Effects.task
)
- GoLoggedInView users me monthlyPayments payments paymentsCount payers ->
- ( { model | view = V.LoggedInView (initLoggedInView users me monthlyPayments payments paymentsCount payers) }
- , Effects.none
- )
-
- ServerCommunication communication ->
+ SetIncome currentTime amount ->
( model
- , sendRequest communication
+ , Server.setIncome currentTime amount
|> flip Task.onError (always <| Task.succeed NoOp)
|> Effects.task
)
+ GoLoggedInView users me monthlyPayments payments paymentsCount payers ->
+ ( { model | view = V.LoggedInView (initLoggedInView users me monthlyPayments payments paymentsCount payers) }
+ , Effects.none
+ )
+
UpdateTime time ->
({ model | currentTime = time }, Effects.none)
@@ -63,6 +62,13 @@ update action model =
UpdateLoggedIn loggedInAction ->
applyLoggedIn model loggedInAction
+ SignOut ->
+ ( model
+ , Server.signOut
+ |> flip Task.onError (always <| Task.succeed NoOp)
+ |> Effects.task
+ )
+
applySignIn : Model -> SignInAction -> Model
applySignIn model signInAction =
case model.view of
@@ -77,7 +83,7 @@ applyLoggedIn model loggedInAction =
V.LoggedInView loggedInView ->
let (loggedInView, effects) = updateLoggedIn model loggedInAction loggedInView
in ( { model | view = V.LoggedInView loggedInView }
- , effects
+ , Effects.map UpdateLoggedIn effects
)
_ ->
(model, Effects.none)