Reduce parameter down to a record.

This commit is contained in:
Dillon Kearns 2021-04-22 16:24:55 -07:00
parent 4c9c365887
commit 25b6a4f2f2
2 changed files with 29 additions and 56 deletions

View File

@ -416,10 +416,8 @@ initLegacy renderRequest { secrets, mode, staticHttpCache } contentCache config
RenderRequest.FullBuild ->
Nothing
in
StaticResponses.nextStep config mode secrets staticHttpCache [] staticResponses Nothing
|> nextStepToEffect contentCache
config
initialModel =
{ staticResponses = staticResponses
, secrets = secrets
, errors = []
@ -430,6 +428,11 @@ initLegacy renderRequest { secrets, mode, staticHttpCache } contentCache config
, staticRoutes = unprocessedPagesState
, maybeRequestJson = renderRequest
}
in
StaticResponses.nextStep config initialModel Nothing
|> nextStepToEffect contentCache
config
initialModel
updateAndSendPortIfDone :
@ -440,19 +443,11 @@ updateAndSendPortIfDone :
updateAndSendPortIfDone contentCache config model =
StaticResponses.nextStep
config
model.mode
model.secrets
model.allRawResponses
model.errors
model.staticResponses
model
Nothing
|> nextStepToEffect contentCache config model
--, { model | unprocessedPages = List.drop 1 model.unprocessedPages }
update :
ContentCache
-> ProgramConfig userMsg userModel route siteStaticData pageStaticData sharedStaticData
@ -516,11 +511,7 @@ update contentCache config msg model =
}
in
StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
|> nextStepToEffect contentCache config updatedModel
@ -561,26 +552,17 @@ update contentCache config msg model =
}
in
StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
|> nextStepToEffect contentCache config updatedModel
Continue ->
-- TODO
let
updatedModel =
model
in
StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
|> nextStepToEffect contentCache config updatedModel
@ -618,11 +600,7 @@ update contentCache config msg model =
}
in
StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
|> nextStepToEffect contentCache config updatedModel
@ -635,11 +613,7 @@ update contentCache config msg model =
}
in
StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
|> nextStepToEffect contentCache config updatedModel
@ -706,11 +680,7 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
config
updatedModel
(StaticResponses.nextStep config
updatedModel.mode
updatedModel.secrets
updatedModel.allRawResponses
updatedModel.errors
updatedModel.staticResponses
updatedModel
Nothing
)

View File

@ -171,17 +171,20 @@ nextStep :
)
)
}
-> Mode
-> SecretsDict
-> RequestsAndPending
-> List BuildError
-> StaticResponses
->
{ model
| staticResponses : StaticResponses
, secrets : SecretsDict
, errors : List BuildError
, allRawResponses : Dict String (Maybe String)
, mode : Mode
}
-> Maybe (List route)
-> ( StaticResponses, NextStep route )
nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes =
nextStep config ({ mode, secrets, allRawResponses, errors } as model) maybeRoutes =
let
staticResponses =
case staticResponses_ of
case model.staticResponses of
StaticResponses s ->
s
@ -372,13 +375,13 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
secureUrl
)
in
( staticResponses_, Continue newAllRawResponses newThing maybeRoutes )
( model.staticResponses, Continue newAllRawResponses newThing maybeRoutes )
Err error_ ->
( staticResponses_, Finish (ToJsPayload.Errors <| (error_ ++ failedRequests ++ errors)) )
( model.staticResponses, Finish (ToJsPayload.Errors <| (error_ ++ failedRequests ++ errors)) )
else
case staticResponses_ of
case model.staticResponses of
GettingInitialData (NotFetched _ _) ->
let
resolvedRoutes : Result StaticHttpRequest.Error (List route)
@ -425,7 +428,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
)
Err error_ ->
( staticResponses_
( model.staticResponses
, Finish
(ToJsPayload.Errors <|
([ StaticHttpRequest.toBuildError
@ -459,7 +462,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
-- )
--
-- Ok okSiteStaticData ->
( staticResponses_
( model.staticResponses
, ToJsPayload.toJsPayload
(encode allRawResponses mode staticResponses)
generatedOkayFiles