Oops, fix silly mistake when combining zones by label on the item page
Oh, right, silly: my previous version of this change still grouped by zone, then mapped the zones to their labels. This didn't *merge* the lists of appearances for zones that share the same label; just one of the zones would win, and the others would disappear. In this change, I just go upstream and actually group them by label in the first place, instead of grouping by zone then trying to merge and transform them.
This commit is contained in:
parent
28cdef29d0
commit
3940513244
2 changed files with 6 additions and 10 deletions
|
@ -99,8 +99,7 @@ class ItemsController < ApplicationController
|
|||
|
||||
@all_appearances = @item.appearances
|
||||
@appearances_by_occupied_zone_label =
|
||||
@item.appearances_by_occupied_zone.
|
||||
transform_keys(&:label).sort_by { |l, a| l }
|
||||
@item.appearances_by_occupied_zone_label.sort_by { |l, a| l }
|
||||
@selected_item_appearance = @preview_outfit.item_appearances.first
|
||||
|
||||
@preview_pet_type_options = PetType.where(color: @preview_outfit.color).
|
||||
|
|
|
@ -592,22 +592,19 @@ class Item < ApplicationRecord
|
|||
Item.appearances_for([self], target, ...)[id]
|
||||
end
|
||||
|
||||
def appearances_by_occupied_zone_id
|
||||
def appearances_by_occupied_zone_label
|
||||
zones_by_id = occupied_zones.to_h { |z| [z.id, z] }
|
||||
{}.tap do |h|
|
||||
appearances.each do |appearance|
|
||||
appearance.occupied_zone_ids.each do |zone_id|
|
||||
h[zone_id] ||= []
|
||||
h[zone_id] << appearance
|
||||
zone_label = zones_by_id[zone_id].label
|
||||
h[zone_label] ||= []
|
||||
h[zone_label] << appearance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def appearances_by_occupied_zone
|
||||
zones_by_id = occupied_zones.to_h { |z| [z.id, z] }
|
||||
appearances_by_occupied_zone_id.transform_keys { |zid| zones_by_id[zid] }
|
||||
end
|
||||
|
||||
# Given a list of items, return how they look on the given target (either a
|
||||
# pet type or an alt style).
|
||||
def self.appearances_for(items, target, swf_asset_includes: [])
|
||||
|
|
Loading…
Reference in a new issue