aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model.elm
blob: 43a19c53ff9469377777f14c27bfedd352cf5741 (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.Config exposing (..)

type alias Model =
  { view : View
  , currentTime : Time
  , translations : Translations
  , config : Config
  }

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