aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Model.elm')
-rw-r--r--src/client/elm/Model.elm22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/client/elm/Model.elm b/src/client/elm/Model.elm
index a1d2bff..5167e42 100644
--- a/src/client/elm/Model.elm
+++ b/src/client/elm/Model.elm
@@ -4,9 +4,11 @@ module Model exposing
)
import Time exposing (Time)
-import Json.Decode as Json
+import Json.Decode as Decode
-import Html.App as Html
+import Navigation exposing (Location)
+
+import Html as Html
import Page exposing (Page)
import Init as Init exposing (Init)
@@ -38,14 +40,10 @@ type alias Model =
, tooltip : Tooltip.Model
}
-init : Json.Value -> Result String Page -> (Model, Cmd Msg)
-init payload result =
- let page =
- case result of
- Err _ -> Page.Home
- Ok page -> page
- model =
- case Json.decodeValue Init.decoder payload of
+init : Decode.Value -> Location -> (Model, Cmd Msg)
+init payload location =
+ let model =
+ case Decode.decodeValue Init.decoder payload of
Ok { time, translations, conf, result, windowSize } ->
{ view =
case result of
@@ -58,7 +56,7 @@ init payload result =
, currentTime = time
, translations = translations
, conf = conf
- , page = page
+ , page = Page.fromLocation location
, errors = []
, dialog = Dialog.init DialogModel.init Msg.Dialog
, tooltip = Tooltip.init windowSize.width windowSize.height
@@ -68,7 +66,7 @@ init payload result =
, currentTime = 0
, translations = []
, conf = { currency = "" }
- , page = page
+ , page = Page.fromLocation location
, errors = [ error ]
, dialog = Dialog.init DialogModel.init Msg.Dialog
, tooltip = Tooltip.init 0 0