Skip to content

Commit

Permalink
fix(StoryItemRelation): fails when a set item has no position.
Browse files Browse the repository at this point in the history
This is caused by an unknown bug which hasnt been resolved yet.
Reposition items are probably creating invalid set items with nil position.
The change here stops the build_items from failing.
  • Loading branch information
EdwinRozario committed Feb 3, 2022
1 parent e6aa01d commit 33995cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/supplejack/story_item_relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ def respond_to_missing?(_method, *_args, &_blocks)
private

def build_items(items)
@items = items.map do |hash|
Supplejack::StoryItem.new(hash.merge(story_id: story.id, api_key: story.api_key))
end.sort_by(&:position)
story_items = items.map do |item|
Supplejack::StoryItem.new(item.merge(story_id: story.id, api_key: story.api_key))
end

@items = story_items.sort_by { |i| i.position.to_i }
end
end
end

0 comments on commit 33995cd

Please sign in to comment.