From 9f62d7cdbec24697337ebd746571aedb828d117b Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 8 Sep 2024 18:15:27 -0700 Subject: [PATCH] Oops, fix bug with restricted zones from item search in wardrobe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/controllers/items_controller.rb | 6 ++++++ app/javascript/wardrobe-2020/loaders/items.js | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 68362600..3c59e4e3 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -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: { diff --git a/app/javascript/wardrobe-2020/loaders/items.js b/app/javascript/wardrobe-2020/loaders/items.js index fe53941a..603f65e0 100644 --- a/app/javascript/wardrobe-2020/loaders/items.js +++ b/app/javascript/wardrobe-2020/loaders/items.js @@ -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), }; }