From aa6ce12bbeba96cb830ad50591b81009a4e243ed Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 14 Aug 2020 22:09:52 -0700 Subject: [PATCH] add Neopets ID to layer support modal --- src/app/WardrobePage/support/ItemLayerSupportModal.js | 2 ++ src/app/components/useOutfitAppearance.js | 1 + src/server/index.js | 11 +++++++++++ src/server/query-tests/Item.test.js | 1 + .../query-tests/__snapshots__/Item.test.js.snap | 3 +++ 5 files changed, 18 insertions(+) diff --git a/src/app/WardrobePage/support/ItemLayerSupportModal.js b/src/app/WardrobePage/support/ItemLayerSupportModal.js index b608209..768c934 100644 --- a/src/app/WardrobePage/support/ItemLayerSupportModal.js +++ b/src/app/WardrobePage/support/ItemLayerSupportModal.js @@ -132,6 +132,8 @@ function ItemLayerSupportModal({ DTI ID: {itemLayer.id} + Neopets ID: + {itemLayer.remoteId} Zone: {itemLayer.zone.label} ({itemLayer.zone.id}) diff --git a/src/app/components/useOutfitAppearance.js b/src/app/components/useOutfitAppearance.js index 723566a..46d3674 100644 --- a/src/app/components/useOutfitAppearance.js +++ b/src/app/components/useOutfitAppearance.js @@ -118,6 +118,7 @@ export const itemAppearanceFragment = gql` fragment ItemAppearanceForOutfitPreview on ItemAppearance { layers { id + remoteId # HACK: This is for Support tools, but other views don't need it svgUrl imageUrl(size: SIZE_600) swfUrl # HACK: This is for Support tools, but other views don't need it diff --git a/src/server/index.js b/src/server/index.js index 02fc1f1..21bbf52 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -101,7 +101,14 @@ const typeDefs = gql` # Cache for 1 week (unlikely to change) type AppearanceLayer @cacheControl(maxAge: 604800) { + # The DTI ID. Guaranteed unique across all layers of all types. id: ID! + + # The Neopets ID. Guaranteed unique across layers of the _same_ type, but + # not of different types. That is, it's allowed and common for an item + # layer and a pet layer to have the same remoteId. + remoteId: ID! + zone: Zone! imageUrl(size: LayerImageSize): String @@ -326,6 +333,10 @@ const resolvers = { }, }, AppearanceLayer: { + bodyId: async ({ id }, _, { swfAssetLoader }) => { + const layer = await swfAssetLoader.load(id); + return layer.remoteId; + }, bodyId: async ({ id }, _, { swfAssetLoader }) => { const layer = await swfAssetLoader.load(id); return layer.bodyId; diff --git a/src/server/query-tests/Item.test.js b/src/server/query-tests/Item.test.js index be6ed62..191af06 100644 --- a/src/server/query-tests/Item.test.js +++ b/src/server/query-tests/Item.test.js @@ -71,6 +71,7 @@ describe("Item", () => { appearanceOn(speciesId: "54", colorId: "75") { layers { id + remoteId imageUrl(size: SIZE_600) svgUrl zone { diff --git a/src/server/query-tests/__snapshots__/Item.test.js.snap b/src/server/query-tests/__snapshots__/Item.test.js.snap index dd27282..4675b65 100644 --- a/src/server/query-tests/__snapshots__/Item.test.js.snap +++ b/src/server/query-tests/__snapshots__/Item.test.js.snap @@ -9,6 +9,7 @@ Object { Object { "id": "37128", "imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14856/600x600.png?v2-1587653266000", + "remoteId": "14856", "svgUrl": null, "zone": Object { "depth": 30, @@ -35,6 +36,7 @@ Object { Object { "id": "37129", "imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/014/14857/600x600.png?v2-0", + "remoteId": "14857", "svgUrl": null, "zone": Object { "depth": 44, @@ -61,6 +63,7 @@ Object { Object { "id": "30203", "imageUrl": "https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png?v2-0", + "remoteId": "6829", "svgUrl": null, "zone": Object { "depth": 3,