Wire in shared static data more places.

This commit is contained in:
Dillon Kearns 2021-04-22 10:48:23 -07:00
parent 267246aa79
commit 31a659e2d4
4 changed files with 13 additions and 8 deletions

View File

@ -177,6 +177,7 @@ view page globalData staticData =
init :
Maybe Shared.Model
-> Shared.StaticData
-> PageStaticData
-> Maybe Browser.Navigation.Key
->
@ -189,7 +190,7 @@ init :
, metadata : Maybe Route
}
-> ( Model, Cmd Msg )
init currentGlobalModel pageStaticData navigationKey maybePagePath =
init currentGlobalModel sharedStaticData pageStaticData navigationKey maybePagePath =
let
( sharedModel, globalCmd ) =
currentGlobalModel |> Maybe.map (\\m -> ( m, Cmd.none )) |> Maybe.withDefault (Shared.template.init navigationKey maybePagePath)
@ -225,8 +226,8 @@ init currentGlobalModel pageStaticData navigationKey maybePagePath =
update : PageStaticData -> Maybe Browser.Navigation.Key -> Msg -> Model -> ( Model, Cmd Msg )
update pageStaticData navigationKey msg model =
update : Shared.StaticData -> PageStaticData -> Maybe Browser.Navigation.Key -> Msg -> Model -> ( Model, Cmd Msg )
update sharedStaticData pageStaticData navigationKey msg model =
case msg of
MsgGlobal msg_ ->
let
@ -238,7 +239,7 @@ update pageStaticData navigationKey msg model =
)
OnPageChange record ->
(init (Just model.global) pageStaticData navigationKey <|
(init (Just model.global) sharedStaticData pageStaticData navigationKey <|
Just
{ path =
{ path = record.path

View File

@ -201,7 +201,7 @@ init config flags url key =
}
, metadata = config.urlToRoute url
}
|> config.init pageStaticData (Just key)
|> config.init sharedStaticData pageStaticData (Just key)
cmd =
[ userCmd
@ -331,7 +331,7 @@ update config appMsg model =
Ok pageData ->
let
( userModel, userCmd ) =
config.update pageData.pageStaticData (Just model.key) userMsg pageData.userModel
config.update pageData.sharedStaticData pageData.pageStaticData (Just model.key) userMsg pageData.userModel
updatedPageData =
Ok { pageData | userModel = userModel }
@ -364,6 +364,7 @@ update config appMsg model =
let
( userModel, userCmd ) =
config.update
pageData.sharedStaticData
pageData.pageStaticData
(Just model.key)
(config.onPageChange
@ -438,6 +439,7 @@ update config appMsg model =
case model.pageData of
Ok pageData ->
config.update
sharedStaticData
pageStaticData
(Just model.key)
(config.onPageChange

View File

@ -814,6 +814,7 @@ sendSinglePageProgress toJsPayload config model =
pageModel : userModel
pageModel =
config.init
sharedStaticData
pageStaticData
Nothing
(Just

View File

@ -13,7 +13,8 @@ import Url exposing (Url)
type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData sharedStaticData =
{ init :
pageStaticData
sharedStaticData
-> pageStaticData
-> Maybe Browser.Navigation.Key
->
Maybe
@ -25,7 +26,7 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s
, metadata : route
}
-> ( userModel, Cmd userMsg )
, update : pageStaticData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, Cmd userMsg )
, update : sharedStaticData -> pageStaticData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, Cmd userMsg )
, subscriptions : route -> PagePath -> userModel -> Sub userMsg
, sharedStaticData : DataSource.DataSource sharedStaticData
, staticData : route -> DataSource.DataSource pageStaticData