Restore staticResponses update for now to fix some cases.

This commit is contained in:
Dillon Kearns 2020-10-07 11:06:44 -07:00
parent 1a20715be6
commit 962c397d75
3 changed files with 51 additions and 12 deletions

View File

@ -103,8 +103,7 @@ type alias Config pathKey userMsg userModel metadata view =
->
StaticHttp.Request
(List
(Result
String
(Result String
{ path : List String
, content : String
}
@ -435,10 +434,10 @@ nextStepToEffect model nextStep =
model.pendingRequests ++ httpRequests
doNow =
nextAndPending |> List.take 1
nextAndPending
pending =
nextAndPending |> List.drop 1
[]
in
( { model | allRawResponses = updatedAllRawResponses, pendingRequests = pending }
, doNow
@ -465,8 +464,7 @@ staticResponseForPage :
}
)
->
Result
(List BuildError)
Result (List BuildError)
(List
( PagePath pathKey
, StaticHttp.Request

View File

@ -12,6 +12,7 @@ import Pages.StaticHttp as StaticHttp exposing (RequestDetails)
import Pages.StaticHttp.Request as HashRequest
import Pages.StaticHttpRequest as StaticHttpRequest
import RequestsAndPending exposing (RequestsAndPending)
import Result.Extra
import Secrets
import SecretsDict exposing (SecretsDict)
import Set
@ -50,8 +51,7 @@ init :
->
StaticHttp.Request
(List
(Result
String
(Result String
{ path : List String
, content : String
}
@ -165,10 +165,50 @@ update newEntry model =
in
{ model
| allRawResponses = updatedAllResponses
, staticResponses =
case model.staticResponses of
StaticResponses staticResponses ->
staticResponses
|> Dict.map
(\pageUrl entry ->
case entry of
NotFetched request rawResponses ->
let
realUrls =
updatedAllResponses
|> StaticHttpRequest.resolveUrls ApplicationType.Cli request
|> Tuple.second
|> List.map Secrets.maskedLookup
|> List.map HashRequest.hash
includesUrl =
List.member
(HashRequest.hash newEntry.request.masked)
realUrls
in
if includesUrl then
let
updatedRawResponses =
Dict.insert
(HashRequest.hash newEntry.request.masked)
newEntry.response
rawResponses
in
NotFetched request updatedRawResponses
else
entry
)
|> StaticResponses
}
dictCompact : Dict String (Maybe a) -> Dict String a
dictCompact dict =
dict
|> Dict.Extra.filterMap (\key value -> value)
addEntry :
RequestsAndPending
-> String
@ -244,8 +284,7 @@ nextStep :
->
StaticHttp.Request
(List
(Result
String
(Result String
{ path : List String
, content : String
}

View File

@ -780,8 +780,7 @@ startWithHttpCache =
startLowLevel :
StaticHttp.Request
(List
(Result
String
(Result String
{ path : List String
, content : String
}
@ -955,6 +954,9 @@ expectErrorsPort expectedPlainString actualPorts =
actualRichTerminalString
|> normalizeErrorExpectEqual expectedPlainString
[] ->
Expect.fail "Expected single error port. Didn't receive any ports."
_ ->
Expect.fail <| "Expected single error port. Got\n" ++ String.join "\n\n" (List.map Debug.toString actualPorts)