mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Allow showing hashtag autocomplete results without term (#19219)
This commit allows us to type # in the UI and present autocomplete results immediately with the following logic for the topic composer, and reversed for the chat composer: * Categories the user can access and has not muted sorted by `topic_count` * Tags the user can access and has not muted sorted by `topic_count` * Chat channels the user is a member of sorted by `messages_count` So in effect, we allow searching for hashtags without a search term. To do this we add a new `search_without_term` to each data source so each one can define how it wants to handle this logic.
This commit is contained in:
@@ -271,6 +271,7 @@ module DiscourseTagging
|
||||
# exclude_synonyms: exclude synonyms from results
|
||||
# order_search_results: result should be ordered for name search results
|
||||
# order_popularity: order result by topic_count
|
||||
# excluded_tag_names: an array of tag names not to include in the results
|
||||
def self.filter_allowed_tags(guardian, opts = {})
|
||||
selected_tag_ids = opts[:selected_tags] ? Tag.where_name(opts[:selected_tags]).pluck(:id) : []
|
||||
category = opts[:category]
|
||||
@@ -427,6 +428,10 @@ module DiscourseTagging
|
||||
builder.where("id NOT IN (SELECT target_tag_id FROM tags WHERE target_tag_id IS NOT NULL)")
|
||||
end
|
||||
|
||||
if opts[:excluded_tag_names]&.any?
|
||||
builder.where("name NOT IN (?)", opts[:excluded_tag_names])
|
||||
end
|
||||
|
||||
if opts[:limit]
|
||||
if required_tag_ids && term.blank?
|
||||
# override limit so all required tags are shown by default
|
||||
|
||||
Reference in New Issue
Block a user