Don't call onPageChange from UpdateCacheAndUrlNew - it was incorrectly triggering init to be called again when the URL didn't change.

This commit is contained in:
Dillon Kearns 2022-05-06 11:16:39 -07:00
parent 84d518b143
commit f6ccc1ed83

View File

@ -477,30 +477,12 @@ update config appMsg model =
updatedPageData : { userModel : userModel, sharedData : sharedData, actionData : Maybe actionData, pageData : pageData } updatedPageData : { userModel : userModel, sharedData : sharedData, actionData : Maybe actionData, pageData : pageData }
updatedPageData = updatedPageData =
{ userModel = userModel { userModel = previousPageData.userModel
, sharedData = newSharedData , sharedData = newSharedData
, pageData = newPageData , pageData = newPageData
, actionData = newActionData , actionData = newActionData
} }
( userModel, userCmd ) =
-- TODO call update on new Model for ErrorPage
config.update
newSharedData
newPageData
model.key
(config.onPageChange
{ protocol = model.url.protocol
, host = model.url.host
, port_ = model.url.port_
, path = newUrl |> urlPathToPath
, query = newUrl.query
, fragment = newUrl.fragment
, metadata = config.urlToRoute newUrl
}
)
previousPageData.userModel
updatedModel : Model userModel pageData actionData sharedData updatedModel : Model userModel pageData actionData sharedData
updatedModel = updatedModel =
{ model { model
@ -514,8 +496,7 @@ update config appMsg model =
| ariaNavigationAnnouncement = mainView config updatedModel |> .title | ariaNavigationAnnouncement = mainView config updatedModel |> .title
} }
, Batch , Batch
[ UserCmd userCmd [ ScrollToTop
, ScrollToTop
, if fromLinkClick || urlWithoutRedirectResolution.path /= newUrl.path then , if fromLinkClick || urlWithoutRedirectResolution.path /= newUrl.path then
BrowserPushUrl newUrl.path BrowserPushUrl newUrl.path
@ -530,8 +511,7 @@ update config appMsg model =
| ariaNavigationAnnouncement = mainView config updatedModel |> .title | ariaNavigationAnnouncement = mainView config updatedModel |> .title
} }
, Batch , Batch
[ UserCmd userCmd [ ScrollToTop
, ScrollToTop
, if fromLinkClick || urlWithoutRedirectResolution.path /= newUrl.path then , if fromLinkClick || urlWithoutRedirectResolution.path /= newUrl.path then
BrowserPushUrl newUrl.path BrowserPushUrl newUrl.path