diff options
author | Joris | 2016-03-31 00:06:50 +0200 |
---|---|---|
committer | Joris | 2016-03-31 00:13:25 +0200 |
commit | c95e19407d492a0d4e9e14e320520fe29ce379e5 (patch) | |
tree | ca6a14ad1396af6a4bc36e17ce89278d5dbea0a0 /src/client/elm/Main.elm | |
parent | c542551ad043260e6a4a6569b4af5c748f7b6001 (diff) |
Add init data in html page
Diffstat (limited to 'src/client/elm/Main.elm')
-rw-r--r-- | src/client/elm/Main.elm | 22 |
1 files changed, 8 insertions, 14 deletions
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 |