mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Change url after updating cache.
This commit is contained in:
parent
911ec43d9a
commit
bbe1da41de
@ -254,6 +254,7 @@ type Msg userMsg metadata view
|
||||
| UrlChanged Url.Url
|
||||
| UserMsg userMsg
|
||||
| UpdateCache (Result Http.Error (ContentCache userMsg metadata view))
|
||||
| UpdateCacheAndUrl Url (Result Http.Error (ContentCache userMsg metadata view))
|
||||
|
||||
|
||||
type Model userModel userMsg metadata view
|
||||
@ -308,7 +309,7 @@ update markupParser markdownToHtml userUpdate msg model =
|
||||
}
|
||||
, model.contentCache
|
||||
|> ContentCache.lazyLoad markupParser model.imageAssets markdownToHtml url
|
||||
|> Task.attempt UpdateCache
|
||||
|> Task.attempt (UpdateCacheAndUrl url)
|
||||
)
|
||||
|
||||
UserMsg userMsg ->
|
||||
@ -329,6 +330,17 @@ update markupParser markdownToHtml userUpdate msg model =
|
||||
-- TODO handle error
|
||||
( model, Cmd.none )
|
||||
|
||||
UpdateCacheAndUrl url cacheUpdateResult ->
|
||||
case cacheUpdateResult of
|
||||
-- TODO can there be race conditions here? Might need to set something in the model
|
||||
-- to keep track of the last url change
|
||||
Ok updatedCache ->
|
||||
( { model | url = url, contentCache = updatedCache }, Cmd.none )
|
||||
|
||||
Err _ ->
|
||||
-- TODO handle error
|
||||
( { model | url = url }, Cmd.none )
|
||||
|
||||
|
||||
warmupCache markupParser markdownToHtml url model =
|
||||
{ model
|
||||
|
Loading…
Reference in New Issue
Block a user