1
mirror of https://github.com/thepeacockproject/Peacock synced 2025-02-16 16:34:28 +01:00

fix: add states to challenges during transfer if empty

Co-authored-by: Reece Dunham <me@rdil.rocks>
This commit is contained in:
Alexandre Sanchez 2024-05-20 23:22:11 +02:00 committed by Reece Dunham
parent 644cda83f9
commit 55c85f1789

View File

@ -67,6 +67,7 @@ if (PEACOCK_DEV) {
"GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
)
res.set("Access-Control-Allow-Headers", "content-type")
res.set("Content-Type", "application/json")
next()
})
}
@ -374,17 +375,26 @@ webFeaturesRouter.post(
userdata.Extensions.ChallengeProgression = Object.fromEntries(
challengeProgression.data.map((data) => {
return [
data.ChallengeId,
{
Ticked: data.Completed,
Completed: data.Completed,
CurrentState:
(data.State["CurrentState"] as string) ??
"Start",
State: data.State,
},
]
const dataObject = {
Ticked: data.Completed,
Completed: data.Completed,
CurrentState:
(data.State["CurrentState"] as string) ?? "Start",
State: data.State,
}
if (Object.keys(data.State).length < 1) {
const peacockChallenge =
controller.challengeService.getChallengeById(
data.ChallengeId,
req.query.gv as Exclude<GameVersion, "scpc">,
)
dataObject.State =
peacockChallenge?.Definition.Context || {}
}
return [data.ChallengeId, dataObject]
}),
)