Simplify recommended index component parameters

We can get the path if we know the namespace, so we don't need to pass
both of them.
This commit is contained in:
Javi Martín
2025-07-02 15:11:46 +02:00
parent 3347e85017
commit 054fbf585e
3 changed files with 14 additions and 9 deletions

View File

@@ -1,14 +1,23 @@
class Shared::RecommendedIndexComponent < ApplicationComponent
attr_reader :recommendations, :disable_recommendations_path, :namespace
attr_reader :recommendations, :namespace
use_helpers :current_path_with_query_params
def initialize(recommendations, disable_recommendations_path:, namespace:)
def initialize(recommendations, namespace:)
@recommendations = recommendations
@disable_recommendations_path = disable_recommendations_path
@namespace = namespace
end
def render?
feature?("user.recommendations") && recommendations.present?
end
private
def disable_recommendations_path
if namespace == "debates"
recommendations_disable_debates_path
else
recommendations_disable_proposals_path
end
end
end