Skip to content

Commit

Permalink
fix: update code to handle case where there are no follows
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef-Rousset committed May 22, 2024
1 parent 5ac5c40 commit 148a906
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ def run_after_hooks
follows = Decidim::Follow.where(user:)
ids << follows.where(decidim_followable_type: resource.privatable_to_type)
.where(decidim_followable_id: space.id)
.first.id
&.first&.id
children_ids = follows.select { |follow| find_object_followed(follow).respond_to?("decidim_component_id") }
.select { |follow| space.components.ids.include?(find_object_followed(follow).decidim_component_id) }
.map(&:id)
&.map(&:id)
ids << children_ids

follows.where(id: ids.flatten).destroy_all if ids.present?
end

Expand Down

0 comments on commit 148a906

Please sign in to comment.