From 97ec2c5ff4907e73019bae598714613469adccda Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Thu, 12 Dec 2024 12:29:35 -0300 Subject: [PATCH] FEATURE: Show gists everywhere except suggested/related (#995) --- assets/javascripts/discourse/services/gists.js | 12 +++--------- lib/summarization/entry_point.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/assets/javascripts/discourse/services/gists.js b/assets/javascripts/discourse/services/gists.js index 057492ac..de939bcd 100644 --- a/assets/javascripts/discourse/services/gists.js +++ b/assets/javascripts/discourse/services/gists.js @@ -7,15 +7,9 @@ export default class Gists extends Service { @tracked preference = localStorage.getItem("topicListLayout"); get shouldShow() { - const currentRoute = this.router.currentRoute.name; - const isDiscovery = currentRoute.includes("discovery"); - const isNotCategories = !currentRoute.includes("categories"); - const gistsAvailable = - this.router.currentRoute.attributes?.list?.topics?.some( - (topic) => topic.ai_topic_gist - ); - - return isDiscovery && isNotCategories && gistsAvailable; + return this.router.currentRoute.attributes?.list?.topics?.some( + (topic) => topic.ai_topic_gist + ); } setPreference(value) { diff --git a/lib/summarization/entry_point.rb b/lib/summarization/entry_point.rb index b706eec7..ba876356 100644 --- a/lib/summarization/entry_point.rb +++ b/lib/summarization/entry_point.rb @@ -17,9 +17,12 @@ module DiscourseAi scope.can_see_summary?(object.topic) end + # Don't add gists to the following topic lists. + gist_skipped_lists = %i[suggested semantic_related] + plugin.register_modifier(:topic_query_create_list_topics) do |topics, options| - if Discourse.filters.include?(options[:filter]) && SiteSetting.ai_summarization_enabled && - SiteSetting.ai_summary_gists_enabled + if SiteSetting.ai_summarization_enabled && SiteSetting.ai_summary_gists_enabled && + !gist_skipped_lists.include?(options[:filter]) topics.includes(:ai_gist_summary) else topics @@ -31,7 +34,7 @@ module DiscourseAi :ai_topic_gist, include_condition: -> { scope.can_see_gists? }, ) do - return if !Discourse.filters.include?(options[:filter]) + return if gist_skipped_lists.include?(options[:filter]) object.ai_gist_summary&.summarized_text end