From 166cd04e4b28770ede854dafc9ae30eae64102fe Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 28 Mar 2016 17:51:14 +0200 Subject: Create an empty but reachable user page --- src/client/elm/Main.elm | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'src/client/elm/Main.elm') diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm index 0ba25b7..ac70202 100644 --- a/src/client/elm/Main.elm +++ b/src/client/elm/Main.elm @@ -3,11 +3,12 @@ module Main ) where import Graphics.Element exposing (..) +import Json.Decode as Json import Html exposing (Html) import StartApp exposing (App) import Effects exposing (Effects, Never) -import Json.Decode as Json +import TransitRouter import Task exposing (..) import Time exposing (..) @@ -16,34 +17,48 @@ import Server import Action exposing (..) import Model exposing (Model, initialModel) -import Update exposing (update) +import Update exposing (update, routerConfig) import View exposing (view) import Utils.Maybe exposing (isJust) +import Utils.Effects as Effects main : Signal Html main = app.html app : App Model app = StartApp.start - { init = - case Json.decodeString Json.string signInError of - Ok signInError -> - ( initialModel initialTime translations conf (Just signInError) - , Effects.none - ) - Err _ -> - ( initialModel initialTime translations conf Nothing - , Server.init - |> Task.map GoLoggedInView - |> flip Task.onError (always <| Task.succeed GoSignInView) - |> Effects.task - ) + { init = initData `Effects.andThen` initRouter , view = view , update = update - , inputs = [ Signal.map UpdateTime (Time.every 1000) ] + , inputs = + [ Signal.map UpdateTime (Time.every 1000) + , Signal.map RouterAction TransitRouter.actions + ] } +-- Init + +initData : (Model, Effects Action) +initData = + case Json.decodeString Json.string signInError of + Ok signInError -> + ( initialModel initialTime translations conf (Just signInError) + , Effects.none + ) + Err _ -> + ( initialModel initialTime translations conf Nothing + , Server.init + |> Task.map GoLoggedInView + |> flip Task.onError (always <| Task.succeed GoSignInView) + |> Effects.task + ) + +initRouter : Model -> (Model, Effects Action) +initRouter model = TransitRouter.init routerConfig location model + +-- Output ports + port tasks : Signal (Task.Task Never ()) port tasks = app.tasks @@ -53,3 +68,4 @@ port initialTime : Time port translations : String port conf : String port signInError : String +port location : String -- cgit v1.2.3