Use save function on template model updates.

This commit is contained in:
Dillon Kearns 2020-09-01 17:39:05 -07:00
parent 94f018e2ae
commit 3a0196b69d
2 changed files with 43 additions and 6 deletions

View File

@ -168,12 +168,25 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
`
).join("\n ")}
save : TemplateModel -> Global.Model -> Global.Model
save model globalModel=
case model of
${templates.map(name => `Model${name} m ->
Template.${name}.template.save m globalModel
`
).join("\n ")}
NotFound ->
globalModel
mainTemplate { documents, manifest, canonicalSiteUrl, subscriptions } =
Pages.Platform.init
{ init = init

View File

@ -446,7 +446,7 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
MsgBlogPost msg_ ->
@ -463,7 +463,7 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
MsgDocumentation msg_ ->
@ -480,7 +480,7 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
MsgPage msg_ ->
@ -497,7 +497,7 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
MsgShowcase msg_ ->
@ -514,11 +514,35 @@ update msg model =
_ ->
( model.page, Cmd.none )
in
( { model | page = updatedPageModel }, pageCmd )
( { model | page = updatedPageModel, global = save updatedPageModel model.global }, pageCmd )
save : TemplateModel -> Global.Model -> Global.Model
save model globalModel=
case model of
ModelBlogIndex m ->
Template.BlogIndex.template.save m globalModel
ModelBlogPost m ->
Template.BlogPost.template.save m globalModel
ModelDocumentation m ->
Template.Documentation.template.save m globalModel
ModelPage m ->
Template.Page.template.save m globalModel
ModelShowcase m ->
Template.Showcase.template.save m globalModel
NotFound ->
globalModel
mainTemplate { documents, manifest, canonicalSiteUrl, subscriptions } =
Pages.Platform.init
{ init = init