Skip to content

Commit

Permalink
EDITOR-NTUEELightDance#94 fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
justhowww committed Feb 13, 2022
1 parent 4ad57b0 commit 939f62b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
44 changes: 26 additions & 18 deletions editor-server/src/resolvers/controlMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,32 @@ export class EditControlMapResolver {
controlData.map(async (dancerParts: any) => {
// data for one of the dancers
const { dancerName, controlData } = dancerParts;
await Promise.all(controlData.map(async (partData: any) => {
// for the part of a certain dancer, create a new control of the part with designated value
const value = await examineType(partData, ctx);
let newControl = await new ctx.db.Control({
frame: newControlFrame,
value,
id: generateID(),
});
await ctx.db.Part.findOneAndUpdate(
{ name: partData.partName },
{
$push: {
controlData: newControl,
},
}
);
await newControl.save();
}))
await Promise.all(
controlData.map(async (partData: any) => {
const dancer = await ctx.db.Dancer.findOne({
name: dancerName,
}).populate({
path: "parts",
match: { name: partData.partName },
});
// for the part of a certain dancer, create a new control of the part with designated value
const value = await examineType(partData, ctx);
let newControl = new ctx.db.Control({
frame: newControlFrame,
value,
id: generateID(),
});
await ctx.db.Part.findOneAndUpdate(
{ id: dancer.parts[0].id },
{
$push: {
controlData: newControl,
},
}
);
await newControl.save();
})
);
})
);

Expand Down
6 changes: 3 additions & 3 deletions editor-server/src/resolvers/positionFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export class PositionFrameResolver {
{ id: input.frameID },
{ editing: null }
);
const positionFrame = await ctx.db.PositionFrame.findOne(
{ id: input.frameID }
);
const positionFrame = await ctx.db.PositionFrame.findOne({
id: input.frameID,
});
await updateRedisPosition(positionFrame.id);
const payload: PositionMapPayload = {
mutation: PositionMapMutation.CREATED,
Expand Down
18 changes: 10 additions & 8 deletions editor-server/src/resolvers/positionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,16 @@ export class EditPosMapResolver {
name: dancerName,
}).populate("positionData");

await Promise.all(dancer.positionData.map(async (position: any) => {
if (position.frame.toString() === _id.toString()) {
await ctx.db.Position.updateOne(
{ _id: position._id },
{ x: positionData.x, y: positionData.y, z: positionData.z }
);
}
}))
await Promise.all(
dancer.positionData.map(async (position: any) => {
if (position.frame.toString() === _id.toString()) {
await ctx.db.Position.updateOne(
{ _id: position._id },
{ x: positionData.x, y: positionData.y, z: positionData.z }
);
}
})
);
})
);

Expand Down

0 comments on commit 939f62b

Please sign in to comment.