From c95e19407d492a0d4e9e14e320520fe29ce379e5 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 31 Mar 2016 00:06:50 +0200 Subject: Add init data in html page --- src/client/elm/Main.elm | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/client/elm/Main.elm') diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm index 561ea91..0813573 100644 --- a/src/client/elm/Main.elm +++ b/src/client/elm/Main.elm @@ -17,6 +17,7 @@ import Server import Mailbox import Action exposing (..) import Model exposing (Model, initialModel) +import Model.InitResult as InitResult exposing (initResultDecoder) import Update exposing (update, routerConfig) import View exposing (view) @@ -28,7 +29,7 @@ main = app.html app : App Model app = StartApp.start - { init = initData `Effects.andThen` initRouter + { init = (initData, Effects.none) `Effects.andThen` initRouter , view = view , update = update , inputs = @@ -40,20 +41,13 @@ app = StartApp.start -- Init -initData : (Model, Effects Action) +initData : Model initData = - case Json.decodeString Json.string signInError of - Ok signInError -> - ( initialModel initialTime translations conf (Just signInError) - , Effects.none - ) + case Json.decodeString initResultDecoder initResult of + Ok init -> + initialModel initialTime translations conf init Err _ -> - ( initialModel initialTime translations conf Nothing - , Server.init - |> Task.map GoLoggedInView - |> flip Task.onError (always <| Task.succeed GoSignInView) - |> Effects.task - ) + initialModel initialTime translations conf InitResult.InitEmpty initRouter : Model -> (Model, Effects Action) initRouter model = TransitRouter.init routerConfig location model @@ -68,5 +62,5 @@ port tasks = app.tasks port initialTime : Time port translations : String port conf : String -port signInError : String +port initResult : String port location : String -- cgit v1.2.3