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/Model.elm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/client/elm/Model.elm') diff --git a/src/client/elm/Model.elm b/src/client/elm/Model.elm index 9e3f4a0..b4213d5 100644 --- a/src/client/elm/Model.elm +++ b/src/client/elm/Model.elm @@ -12,6 +12,8 @@ import Route exposing (Route) import Model.View exposing (..) import Model.Translations exposing (..) import Model.Conf exposing (..) +import Model.InitResult exposing (..) +import LoggedIn.Model as LoggedInModel import SignIn.Model as SignInModel @@ -25,12 +27,16 @@ type alias Model = , transitRouter : TransitRouter.TransitRouter Route } -initialModel : Time -> String -> String -> Maybe String -> Model -initialModel initialTime translations conf mbSignInError = +initialModel : Time -> String -> String -> InitResult -> Model +initialModel initialTime translations conf initResult = { view = - if isJust mbSignInError - then SignInView (SignInModel.init mbSignInError) - else LoadingView + case initResult of + InitEmpty -> + SignInView (SignInModel.init Nothing) + InitSuccess init -> + LoggedInView (LoggedInModel.init init) + InitError error -> + SignInView (SignInModel.init (Just error)) , currentTime = initialTime , translations = case Json.decodeString translationsDecoder translations of -- cgit v1.2.3