From f40ccf0b2153086587d4a2318b1c81f30a10a1e0 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 20 Jan 2021 10:43:41 -0800 Subject: [PATCH] Fix bug where we weren't recognizing new SVGs So, we've been behind the latest conversion data for a while anyway, because I don't run the sync very often. But I ran the sync today and noticed that the newly converted SVGs weren't showing up in DTI! This is because TNT changed the asset manifest structure they use for SVG-only assets. Now, we support both! To test, I checked the Blue Acara (old-style SVG manifest), the Blue Chia (new-style SVG manifest), and the Floating Negg Faerie Doll (animated clip). --- src/server/types/AppearanceLayer.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/server/types/AppearanceLayer.js b/src/server/types/AppearanceLayer.js index 95ac71e..c82ff29 100644 --- a/src/server/types/AppearanceLayer.js +++ b/src/server/types/AppearanceLayer.js @@ -153,16 +153,28 @@ const resolvers = { } const asset = manifest.assets[0]; - if (asset.format !== "vector") { + if (asset.format !== "vector" && asset.format !== "lod") { return null; } - if (asset.assetData.length !== 1) { + // In the `lod` case, if there's a JS asset, then don't treat this as an + // SVG asset at all. (There might be an SVG in the asset list anyway + // sometimes I think, for the animation, but ignore it if so!) + const jsAssetDatum = asset.assetData.find((ad) => + ad.path.endsWith(".js") + ); + if (jsAssetDatum) { return null; } - const assetDatum = asset.assetData[0]; - const url = new URL(assetDatum.path, "http://images.neopets.com"); + const svgAssetDatum = asset.assetData.find((ad) => + ad.path.endsWith(".svg") + ); + if (!svgAssetDatum) { + return null; + } + + const url = new URL(svgAssetDatum.path, "http://images.neopets.com"); return url.toString(); }, canvasMovieLibraryUrl: async ({ id }, _, { db, swfAssetLoader }) => {