module Model
  ( Model
  , initialModel
  ) where

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

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

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

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