From a11ad41b52ed3682d33382f2a378bf3294d688b2 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 23 Mar 2016 00:45:33 +0100 Subject: Sign in token link to / --- src/client/elm/Main.elm | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/client/elm/Main.elm') diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm index 06b5ec3..c3d5192 100644 --- a/src/client/elm/Main.elm +++ b/src/client/elm/Main.elm @@ -7,6 +7,7 @@ import Graphics.Element exposing (..) import Html exposing (Html) import StartApp exposing (App) import Effects exposing (Effects, Never) +import Json.Decode as Json import Task exposing (..) import Time exposing (..) @@ -20,18 +21,26 @@ import View exposing (view) import Server +import Utils.Maybe exposing (isJust) + main : Signal Html main = app.html app : App Model app = StartApp.start { init = - ( initialModel initialTime translations conf - , Server.init - |> Task.map GoLoggedInView - |> flip Task.onError (always <| Task.succeed GoSignInView) - |> Effects.task - ) + 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 + ) , view = view , update = update , inputs = [ Signal.map UpdateTime (Time.every 1000) ] @@ -45,7 +54,4 @@ port tasks = app.tasks port initialTime : Time port translations : String port conf : String - --- Output ports - -port signInError : Maybe String +port signInError : String -- cgit v1.2.3