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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user