From 874402403120e3397a589674b46c5d838a606a72 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Wed, 21 Apr 2021 07:11:19 -0700 Subject: [PATCH] Remove obsolete Maybe. --- .../src/generate-template-module-connector.js | 2 +- src/Pages/Internal/Platform.elm | 62 ++++++++----------- src/Pages/ProgramConfig.elm | 14 ++--- 3 files changed, 33 insertions(+), 45 deletions(-) diff --git a/generator/src/generate-template-module-connector.js b/generator/src/generate-template-module-connector.js index 3d997735..545a3148 100644 --- a/generator/src/generate-template-module-connector.js +++ b/generator/src/generate-template-module-connector.js @@ -370,7 +370,7 @@ main = [ Shared.template.subscriptions path model.global |> Sub.map MsgGlobal , templateSubscriptions route path model ] - , onPageChange = Just OnPageChange + , onPageChange = OnPageChange , toJsPort = toJsPort , fromJsPort = fromJsPort identity , staticData = staticDataForRoute diff --git a/src/Pages/Internal/Platform.elm b/src/Pages/Internal/Platform.elm index 193f9ff7..71063de3 100644 --- a/src/Pages/Internal/Platform.elm +++ b/src/Pages/Internal/Platform.elm @@ -363,22 +363,17 @@ update config appMsg model = Ok ( ( _, contentJson, updatedCache ), pageData ) -> let ( userModel, userCmd ) = - case config.onPageChange of - Just onPageChangeMsg -> - config.update - pageData.pageStaticData - (Just model.key) - (onPageChangeMsg - { path = urlToPagePath url model.baseUrl - , query = url.query - , fragment = url.fragment - , metadata = config.urlToRoute url - } - ) - pageData.userModel - - _ -> - ( pageData.userModel, Cmd.none ) + config.update + pageData.pageStaticData + (Just model.key) + (config.onPageChange + { path = urlToPagePath url model.baseUrl + , query = url.query + , fragment = url.fragment + , metadata = config.urlToRoute url + } + ) + pageData.userModel in ( { model | url = url @@ -440,27 +435,22 @@ update config appMsg model = let updateResult = if from404ToNon404 then - case config.onPageChange of - Just onPageChangeMsg -> - case model.pageData of - Ok pageData -> - config.update - pageStaticData - (Just model.key) - (onPageChangeMsg - { path = urlToPagePath model.url model.baseUrl - , query = model.url.query - , fragment = model.url.fragment - , metadata = config.urlToRoute model.url - } - ) - pageData.userModel - |> Just + case model.pageData of + Ok pageData -> + config.update + pageStaticData + (Just model.key) + (config.onPageChange + { path = urlToPagePath model.url model.baseUrl + , query = model.url.query + , fragment = model.url.fragment + , metadata = config.urlToRoute model.url + } + ) + pageData.userModel + |> Just - Err error -> - Nothing - - _ -> + Err error -> Nothing else diff --git a/src/Pages/ProgramConfig.elm b/src/Pages/ProgramConfig.elm index 4ed29c5f..ab5f3153 100644 --- a/src/Pages/ProgramConfig.elm +++ b/src/Pages/ProgramConfig.elm @@ -57,12 +57,10 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s ) ) , onPageChange : - Maybe - ({ path : PagePath - , query : Maybe String - , fragment : Maybe String - , metadata : route - } - -> userMsg - ) + { path : PagePath + , query : Maybe String + , fragment : Maybe String + , metadata : route + } + -> userMsg }