aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Main.elm
blob: c3d5192cbac6664ca423501f0ff7ff5ba05b26ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module Main
  ( main
  ) where

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 (..)

import Model exposing (Model, initialModel)
import Model.Action exposing (..)

import Update exposing (update)

import View exposing (view)

import Server

import Utils.Maybe exposing (isJust)

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
          )
  , view = view
  , update = update
  , inputs = [ Signal.map UpdateTime (Time.every 1000) ]
  }

port tasks : Signal (Task.Task Never ())
port tasks = app.tasks

-- Input ports

port initialTime : Time
port translations : String
port conf : String
port signInError : String