Make sure send page progress events get kicked off when there are no initial requests from getStaticRoutes or generateFiles.

This commit is contained in:
Dillon Kearns 2021-04-17 07:42:33 -07:00
parent 46ea40c715
commit e11d359222
3 changed files with 57 additions and 17 deletions

View File

@ -699,18 +699,36 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
Nothing ->
model.unprocessedPages
updatedModel =
{ model
| allRawResponses = updatedAllRawResponses
, pendingRequests = pending
, staticResponses = updatedStaticResponsesModel
, staticRoutes = updatedRoutes
, unprocessedPages = updatedUnprocessedPages
}
in
( { model
| allRawResponses = updatedAllRawResponses
, pendingRequests = pending
, staticResponses = updatedStaticResponsesModel
, staticRoutes = updatedRoutes
, unprocessedPages = updatedUnprocessedPages
}
, doNow
|> List.map Effect.FetchHttp
|> Effect.Batch
)
if List.isEmpty doNow && updatedRoutes /= model.staticRoutes then
nextStepToEffect contentCache
config
updatedModel
(StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
Nothing
)
else
( updatedModel
, (doNow
|> List.map Effect.FetchHttp
)
|> Effect.Batch
)
StaticResponses.Finish toJsPayload ->
case model.mode of

View File

@ -415,8 +415,13 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
)
|> Dict.fromList
|> StaticResponses
newThing =
[]
in
nextStep config mode secrets allRawResponses errors newState (Just staticRoutes)
( newState
, Continue allRawResponses newThing (Just staticRoutes)
)
Err error_ ->
( staticResponses_

View File

@ -21,6 +21,7 @@ import Pages.StaticHttp.Request as Request
import PagesHttp
import ProgramTest exposing (ProgramTest)
import Regex
import RenderRequest
import Secrets
import SimulatedEffect.Cmd
import SimulatedEffect.Http as Http
@ -828,7 +829,25 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
|> StaticHttp.succeed
, urlToRoute = .path >> Route
, update = \_ _ _ _ -> ( (), Cmd.none )
, staticData = \_ -> StaticHttp.succeed ()
, staticData =
\(Route pageRoute) ->
let
thing =
pages
|> Dict.fromList
|> Dict.get
(pageRoute
|> String.split "/"
|> List.filter (\pathPart -> pathPart /= "")
)
in
case thing of
Just request ->
--\_ _ -> { view = \_ -> { title = "Title", body = Html.text "" }, head = [] }
request |> StaticHttp.map (\_ -> ())
Nothing ->
Debug.todo <| "Couldn't find page: " ++ pageRoute ++ "\npages: " ++ Debug.toString pages
, site =
\_ ->
{ staticData = StaticHttp.succeed ()
@ -852,9 +871,7 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
in
case thing of
Just request ->
request
|> StaticHttp.map
(\_ -> { view = \_ -> { title = "Title", body = Html.text "" }, head = [] })
\_ _ -> { view = \_ -> { title = "Title", body = Html.text "" }, head = [] }
Nothing ->
Debug.todo <| "Couldn't find page: " ++ Debug.toString page ++ "\npages: " ++ Debug.toString pages
@ -900,7 +917,7 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
-> ( model, Effect pathKey )
-}
ProgramTest.createDocument
{ init = init Nothing identity contentCache config
{ init = init RenderRequest.FullBuild identity contentCache config
, update = update contentCache config
, view = \_ -> { title = "", body = [] }
}