Compare commits

..

No commits in common. "56d550e86cfef3373d204e20b4c3faf3e9c16cda" and "cd095eefcbd367920bac6c6ff2fd4d9fefae1b35" have entirely different histories.

3 changed files with 17 additions and 14 deletions

View file

@ -16,13 +16,10 @@ class AltStylesController < ApplicationController
format.html { render } format.html { render }
format.json { format.json {
render json: @alt_styles.includes(swf_assets: [:zone]).as_json( render json: @alt_styles.includes(swf_assets: [:zone]).as_json(
only: [:id, :species_id, :color_id, :body_id, :series_name,
:adjective_name, :thumbnail_url],
include: { include: {
swf_assets: { swf_assets: {
only: [:id, :body_id],
include: [:zone], include: [:zone],
methods: [:urls, :known_glitches], methods: [:html5_image_url, :html5_svg_url],
} }
}, },
methods: [:series_name, :adjective_name, :thumbnail_url], methods: [:series_name, :adjective_name, :thumbnail_url],

View file

@ -12,10 +12,7 @@ export function useAltStylesForSpecies(speciesId, options = {}) {
// NOTE: This is actually just a wrapper for `useAltStylesForSpecies`, to share // NOTE: This is actually just a wrapper for `useAltStylesForSpecies`, to share
// the same cache key! // the same cache key!
export function useAltStyle(id, speciesId, options = {}) { export function useAltStyle(id, speciesId, options = {}) {
const query = useAltStylesForSpecies(speciesId, { const query = useAltStylesForSpecies(speciesId, options);
...options,
enabled: (options.enabled ?? true) && id != null,
});
return { return {
...query, ...query,
@ -73,11 +70,13 @@ function normalizeSwfAssetToLayer(swfAssetData) {
label: swfAssetData.zone.label, label: swfAssetData.zone.label,
}, },
bodyId: swfAssetData.body_id, bodyId: swfAssetData.body_id,
knownGlitches: swfAssetData.known_glitches, knownGlitches: [], // TODO
svgUrl: swfAssetData.urls.svg, // HACK: We're just simplifying this adapter, but it would be better to
canvasMovieLibraryUrl: swfAssetData.urls.canvas_library, // actually check what file formats the manifest says!
imageUrl: swfAssetData.urls.png, svgUrl: swfAssetData.html5_svg_url,
swfUrl: swfAssetData.urls.swf, canvasMovieLibraryUrl: null,
imageUrl: swfAssetData.html5_image_url,
swfUrl: swfAssetData.url,
}; };
} }

View file

@ -45,7 +45,6 @@ class SwfAsset < ApplicationRecord
swf: url, swf: url,
png: image_url, png: image_url,
svg: manifest_asset_urls[:svg], svg: manifest_asset_urls[:svg],
canvas_library: manifest_asset_urls[:js],
manifest: manifest_url, manifest: manifest_url,
} }
end end
@ -148,6 +147,14 @@ class SwfAsset < ApplicationRecord
).to_s ).to_s
end end
def html5_image_url
manifest_asset_urls[:png]
end
def html5_svg_url
manifest_asset_urls[:svg]
end
def known_glitches def known_glitches
self[:known_glitches].split(',') self[:known_glitches].split(',')
end end