Skip to content

Commit

Permalink
FEATURE: Show gists everywhere except suggested/related (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanrizzi authored Dec 12, 2024
1 parent 04c4ff8 commit 97ec2c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 3 additions & 9 deletions assets/javascripts/discourse/services/gists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions lib/summarization/entry_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ def inject_into(plugin)
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
Expand All @@ -31,7 +34,7 @@ def inject_into(plugin)
: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

Expand Down

0 comments on commit 97ec2c5

Please sign in to comment.