Load item name from Rails app in item preview page

This is just a silly lil single-field migration!
This commit is contained in:
Emi Matchu 2023-11-11 08:50:32 -08:00
parent a31039c4c8
commit b54be0ab5c
2 changed files with 6 additions and 6 deletions

View file

@ -105,6 +105,7 @@ function ItemPageOutfitPreview({ itemId }) {
loading: loadingAppearances, loading: loadingAppearances,
error: errorAppearances, error: errorAppearances,
} = useItemAppearances(itemId); } = useItemAppearances(itemId);
const itemName = itemAppearancesData?.name ?? "";
const itemAppearances = itemAppearancesData?.appearances ?? []; const itemAppearances = itemAppearancesData?.appearances ?? [];
const restrictedZones = itemAppearancesData?.restrictedZones ?? []; const restrictedZones = itemAppearancesData?.restrictedZones ?? [];
@ -132,7 +133,6 @@ function ItemPageOutfitPreview({ itemId }) {
) { ) {
item(id: $itemId) { item(id: $itemId) {
id id
name
canonicalAppearance( canonicalAppearance(
preferredSpeciesId: $preferredSpeciesId preferredSpeciesId: $preferredSpeciesId
preferredColorId: $preferredColorId preferredColorId: $preferredColorId
@ -189,14 +189,13 @@ function ItemPageOutfitPreview({ itemId }) {
// appears in the item name, then this is probably a species-specific item, // appears in the item name, then this is probably a species-specific item,
// and we should adjust the UI to avoid implying that other species could // and we should adjust the UI to avoid implying that other species could
// model it. // model it.
const speciesName =
data?.item?.canonicalAppearance?.body?.canonicalAppearance?.species?.name ??
"";
const isProbablySpeciesSpecific = const isProbablySpeciesSpecific =
compatibleBodies.length === 1 && compatibleBodies.length === 1 &&
compatibleBodies[0] !== "all" && compatibleBodies[0] !== "all" &&
(data?.item?.name || "") itemName.toLowerCase().includes(speciesName.toLowerCase());
.toLowerCase()
.includes(
data?.item?.canonicalAppearance?.body?.canonicalAppearance?.species?.name.toLowerCase(),
);
const couldProbablyModelMoreData = !isProbablySpeciesSpecific; const couldProbablyModelMoreData = !isProbablySpeciesSpecific;
// TODO: Does this double-trigger the HTTP request with SpeciesColorPicker? // TODO: Does this double-trigger the HTTP request with SpeciesColorPicker?

View file

@ -22,6 +22,7 @@ async function loadItemAppearancesData(id) {
function normalizeItemAppearancesData(data) { function normalizeItemAppearancesData(data) {
return { return {
name: data.name,
appearances: data.appearances.map((appearance) => ({ appearances: data.appearances.map((appearance) => ({
body: normalizeBody(appearance.body), body: normalizeBody(appearance.body),
swfAssets: appearance.swf_assets.map((asset) => ({ swfAssets: appearance.swf_assets.map((asset) => ({