skip non-SWF (music) assets
This commit is contained in:
parent
661eea0275
commit
fb8ccee797
3 changed files with 93 additions and 3 deletions
|
@ -171,15 +171,19 @@ const resolvers = {
|
||||||
speciesId: speciesId,
|
speciesId: speciesId,
|
||||||
colorId: colorId,
|
colorId: colorId,
|
||||||
});
|
});
|
||||||
const swfAssets = await itemSwfAssetLoader.load({
|
const allSwfAssets = await itemSwfAssetLoader.load({
|
||||||
itemId: item.id,
|
itemId: item.id,
|
||||||
bodyId: petType.bodyId,
|
bodyId: petType.bodyId,
|
||||||
});
|
});
|
||||||
|
if (allSwfAssets.length === 0) {
|
||||||
if (swfAssets.length === 0) {
|
// If there's no assets at all, treat it as non-fitting: no appearance.
|
||||||
|
// (If there are assets but they're non-SWF, we'll treat this as
|
||||||
|
// fitting, but with an *empty* appearance.)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const swfAssets = allSwfAssets.filter((sa) => sa.url.endsWith(".swf"));
|
||||||
|
|
||||||
const restrictedZones = [];
|
const restrictedZones = [];
|
||||||
for (const [i, bit] of Array.from(item.zonesRestrict).entries()) {
|
for (const [i, bit] of Array.from(item.zonesRestrict).entries()) {
|
||||||
if (bit === "1") {
|
if (bit === "1") {
|
||||||
|
|
|
@ -52,6 +52,7 @@ describe("Item", () => {
|
||||||
layers {
|
layers {
|
||||||
id
|
id
|
||||||
imageUrl(size: SIZE_600)
|
imageUrl(size: SIZE_600)
|
||||||
|
svgUrl
|
||||||
zone {
|
zone {
|
||||||
id
|
id
|
||||||
depth
|
depth
|
||||||
|
@ -133,4 +134,71 @@ describe("Item", () => {
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips appearance data for audio assets", async () => {
|
||||||
|
const res = await query({
|
||||||
|
query: gql`
|
||||||
|
query {
|
||||||
|
items(ids: ["42829"]) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
|
||||||
|
appearanceOn(speciesId: "54", colorId: "75") {
|
||||||
|
layers {
|
||||||
|
id
|
||||||
|
imageUrl(size: SIZE_600)
|
||||||
|
svgUrl
|
||||||
|
zone {
|
||||||
|
id
|
||||||
|
depth
|
||||||
|
label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
restrictedZones {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res).toHaveNoErrors();
|
||||||
|
expect(res.data).toMatchSnapshot();
|
||||||
|
expect(getDbCalls()).toMatchInlineSnapshot(`
|
||||||
|
Array [
|
||||||
|
Array [
|
||||||
|
"SELECT * FROM items WHERE id IN (?)",
|
||||||
|
Array [
|
||||||
|
"42829",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
Array [
|
||||||
|
"SELECT * FROM item_translations WHERE item_id IN (?) AND locale = \\"en\\"",
|
||||||
|
Array [
|
||||||
|
"42829",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
Array [
|
||||||
|
"SELECT * FROM pet_types WHERE (species_id = ? AND color_id = ?)",
|
||||||
|
Array [
|
||||||
|
"54",
|
||||||
|
"75",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
Array [
|
||||||
|
"SELECT sa.*, rel.parent_id FROM swf_assets sa
|
||||||
|
INNER JOIN parents_swf_assets rel ON
|
||||||
|
rel.parent_type = \\"Item\\" AND
|
||||||
|
rel.swf_asset_id = sa.id
|
||||||
|
WHERE (rel.parent_id = ? AND (sa.body_id = ? OR sa.body_id = 0))",
|
||||||
|
Array [
|
||||||
|
"42829",
|
||||||
|
"180",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,7 @@ Object {
|
||||||
Object {
|
Object {
|
||||||
"id": "37128",
|
"id": "37128",
|
||||||
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14856/600x600.png?v2-1587653266000",
|
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14856/600x600.png?v2-1587653266000",
|
||||||
|
"svgUrl": null,
|
||||||
"zone": Object {
|
"zone": Object {
|
||||||
"depth": 30,
|
"depth": 30,
|
||||||
"id": "26",
|
"id": "26",
|
||||||
|
@ -34,6 +35,7 @@ Object {
|
||||||
Object {
|
Object {
|
||||||
"id": "37129",
|
"id": "37129",
|
||||||
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14857/600x600.png?v2-0",
|
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14857/600x600.png?v2-0",
|
||||||
|
"svgUrl": null,
|
||||||
"zone": Object {
|
"zone": Object {
|
||||||
"depth": 44,
|
"depth": 44,
|
||||||
"id": "40",
|
"id": "40",
|
||||||
|
@ -59,6 +61,7 @@ Object {
|
||||||
Object {
|
Object {
|
||||||
"id": "30203",
|
"id": "30203",
|
||||||
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png?v2-0",
|
"imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png?v2-0",
|
||||||
|
"svgUrl": null,
|
||||||
"zone": Object {
|
"zone": Object {
|
||||||
"depth": 3,
|
"depth": 3,
|
||||||
"id": "3",
|
"id": "3",
|
||||||
|
@ -99,3 +102,18 @@ Object {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Item skips appearance data for audio assets 1`] = `
|
||||||
|
Object {
|
||||||
|
"items": Array [
|
||||||
|
Object {
|
||||||
|
"appearanceOn": Object {
|
||||||
|
"layers": Array [],
|
||||||
|
"restrictedZones": Array [],
|
||||||
|
},
|
||||||
|
"id": "42829",
|
||||||
|
"name": "Time Tunnel Music Track",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
Loading…
Reference in a new issue