aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model.elm
blob: 5dc669262293f54e8c664977bb08eae2b77f6d7e (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
module Model
  ( Model
  , initialModel
  ) where

import Time exposing (Time)
import Json.Decode as Json

import Model.View exposing (..)
import Model.Translations exposing (..)
import Model.Conf exposing (..)

type alias Model =
  { view : View
  , currentTime : Time
  , translations : Translations
  , conf : Conf
  }

initialModel : Time -> String -> String -> Model
initialModel initialTime translationsValue confValue =
  { view = LoadingView
  , currentTime = initialTime
  , translations =
      case Json.decodeString translationsDecoder translationsValue of
        Ok translations -> translations
        Err err -> []
  , conf =
      case Json.decodeString confDecoder confValue of
        Ok conf -> conf
        Err err -> { currency = "" }
  }