Skip to content

Commit 3756b6a

Browse files
committed
credentials bugfix
1 parent 857d31c commit 3756b6a

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

server/controllers/handleCancelRace.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { errorHandler, getCredentials, World } from "../utils/index.js";
33
export const handleCancelRace = async (req, res) => {
44
try {
55
const credentials = getCredentials(req.query);
6+
const { urlSlug, profileId, sceneDropId } = credentials;
67

78
const world = await World.create(urlSlug, { credentials });
89

server/utils/checkpoints/finishLineEntered.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { timeToValue } from "../utils.js";
44

55
export const finishLineEntered = async ({ credentials, currentElapsedTime, profileObject, raceObject, world }) => {
66
try {
7-
const { profileId, sceneDropId, urlSlug, username, visitorId } = credentials;
7+
const { profileId, sceneDropId, urlSlug, visitorId } = credentials;
88
const { checkpoints, highscore } = profileObject;
99
const allCheckpointsCompleted = raceObject.numberOfCheckpoints === Object.keys(checkpoints).length;
1010

@@ -13,35 +13,31 @@ export const finishLineEntered = async ({ credentials, currentElapsedTime, profi
1313
const newHighscore =
1414
!highscore || timeToValue(currentElapsedTime) < timeToValue(highscore) ? currentElapsedTime : highscore;
1515

16+
await world.updateDataObject(
17+
{
18+
[`${sceneDropId}.profiles.${profileId}.checkpoints`]: {},
19+
[`${sceneDropId}.profiles.${profileId}.elapsedTime`]: currentElapsedTime,
20+
[`${sceneDropId}.profiles.${profileId}.startTimestamp`]: null,
21+
[`${sceneDropId}.profiles.${profileId}.highscore`]: newHighscore,
22+
},
23+
{ analytics: [{ analyticName: "completions", uniqueKey: profileId }] },
24+
);
25+
1626
if (newHighscore !== highscore) world.triggerActivity({ type: WorldActivityType.GAME_HIGH_SCORE, assetId });
1727

1828
const visitor = await Visitor.get(visitorId, urlSlug, { credentials });
1929
const { x, y } = visitor.moveTo;
2030

21-
await Promise.all(
22-
world.updateDataObject(
23-
{
24-
[`${sceneDropId}.profiles.${profileId}`]: {
25-
checkpoints: {},
26-
elapsedTime: currentElapsedTime,
27-
highscore: newHighscore,
28-
startTimestamp: null,
29-
username,
30-
},
31-
},
32-
{ analytics: [{ analyticName: "completions", uniqueKey: profileId }] },
33-
),
34-
visitor.fireToast({
35-
groupId: "race",
36-
title: "🏁 Finish",
37-
text: `You finished the race! Your time: ${currentElapsedTime}`,
38-
}),
39-
visitor.triggerParticle({
40-
name: "trophy_float",
41-
duration: 3,
42-
position: { x, y },
43-
}),
44-
);
31+
visitor.fireToast({
32+
groupId: "race",
33+
title: "🏁 Finish",
34+
text: `You finished the race! Your time: ${currentElapsedTime}`,
35+
});
36+
visitor.triggerParticle({
37+
name: "trophy_float",
38+
duration: 3,
39+
position: { x, y },
40+
});
4541

4642
return;
4743
} catch (error) {

0 commit comments

Comments
 (0)