Compare commits
No commits in common. "0e1b1eded3453e371356ad2e38854b5dec1fbf16" and "98eb14853cc0194a8b5cae425cc190a5c67864c2" have entirely different histories.
0e1b1eded3
...
98eb14853c
2 changed files with 8 additions and 21 deletions
|
@ -84,7 +84,7 @@ async function handle(req, res) {
|
|||
return reject(
|
||||
res,
|
||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||
500,
|
||||
500
|
||||
);
|
||||
}
|
||||
} else if (req.query.id) {
|
||||
|
@ -101,7 +101,7 @@ async function handle(req, res) {
|
|||
return reject(
|
||||
res,
|
||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||
500,
|
||||
500
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
|||
|
||||
if (errors && errors.length > 0) {
|
||||
throw new Error(
|
||||
`GraphQL Error: ${errors.map((e) => e.message).join(", ")}`,
|
||||
`GraphQL Error: ${errors.map((e) => e.message).join(", ")}`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -197,20 +197,17 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
|||
}
|
||||
|
||||
const { petAppearance, itemAppearances } = data.outfit;
|
||||
|
||||
const visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
||||
visibleLayers.sort((a, b) => a.depth - b.depth);
|
||||
|
||||
const imageUrls = [];
|
||||
for (const layer of visibleLayers) {
|
||||
if (!layer.imageUrl) {
|
||||
console.warn(`layer ${layer.id} has no imageUrl for size ${size}`);
|
||||
continue;
|
||||
throw new Error(`layer ${layer.id} has no imageUrl for size ${size}`);
|
||||
}
|
||||
imageUrls.push(layer.imageUrl);
|
||||
}
|
||||
|
||||
return imageUrls;
|
||||
return visibleLayers
|
||||
.sort((a, b) => a.depth - b.depth)
|
||||
.map((layer) => layer.imageUrl);
|
||||
}
|
||||
|
||||
async function loadUpdatedAtForSavedOutfit(outfitId) {
|
||||
|
@ -233,7 +230,7 @@ function reject(res, message, status = 400) {
|
|||
async function handleWithBeeline(req, res) {
|
||||
beeline.withTrace(
|
||||
{ name: "api/outfitImage", operation_name: "api/outfitImage" },
|
||||
() => handle(req, res),
|
||||
() => handle(req, res)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,11 +73,7 @@ const typeDefs = gql`
|
|||
}
|
||||
|
||||
type PetAppearance @cacheControl(maxAge: ${oneHour}, staleWhileRevalidate: ${oneWeek}) {
|
||||
"""
|
||||
NOTE: In the case of an alt style, this won't match petStateId!
|
||||
"""
|
||||
id: ID!
|
||||
|
||||
species: Species!
|
||||
color: Color!
|
||||
pose: Pose!
|
||||
|
@ -273,12 +269,6 @@ const resolvers = {
|
|||
},
|
||||
|
||||
PetAppearance: {
|
||||
id: ({ id, altStyleId }) => {
|
||||
if (altStyleId != null) {
|
||||
return `${id}-with-alt-style-${altStyleId}`;
|
||||
}
|
||||
return id;
|
||||
},
|
||||
color: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
|
||||
const petState = await petStateLoader.load(id);
|
||||
const petType = await petTypeLoader.load(petState.petTypeId);
|
||||
|
|
Loading…
Reference in a new issue