From cfca18262c1ff48dcb683ddab7d03cf8e55573ff Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 24 Mar 2017 09:21:04 +0000 Subject: Features/categories --- src/client/elm/Model.elm | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/client/elm/Model.elm') 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 -- cgit v1.2.3