Oops, fix bug with restricted zones from item search in wardrobe

Oh oops, I forgot one of the kinds of restricted zones when refactoring
how we load search data in wardrobe-2020! This made most items with
restricted zones (like Be Gone items) not work correctly when you
search for them to add them to the item—though it *does* work correctly
when you reload the page or change the species, to get to load a
different way.
This commit is contained in:
Emi Matchu 2024-09-08 18:15:27 -07:00
parent 27774d908f
commit 9f62d7cdbe
2 changed files with 10 additions and 4 deletions

View file

@ -28,6 +28,12 @@ class ItemsController < ApplicationController
render json: {
items: @items.as_json(
methods: [:nc?, :pb?, :owned?, :wanted?],
include: {
restricted_zones: {
only: [:id, :depth, :label],
methods: [:is_commonly_used_by_items],
},
},
),
appearances: load_appearances.as_json(
include: {

View file

@ -201,10 +201,10 @@ function normalizeItemSearchAppearance(data, item) {
__typename: "ItemAppearance",
id: `item-${item.id}-body-${data.body.id}`,
layers: data.swf_assets.map(normalizeSwfAssetToLayer),
restrictedZones: data.swf_assets
.map((a) => a.restricted_zones)
.flat()
.map(normalizeZone),
restrictedZones: [
...item.restricted_zones,
...data.swf_assets.map((a) => a.restricted_zones).flat(),
].map(normalizeZone),
};
}