DEV: Change HashtagAutocompleteService to use DiscoursePluginRegistry (#19491)

Follow up to a review in #18937, this commit changes the HashtagAutocompleteService to no longer use class variables to register hashtag data sources or types in context priority order. This is to address multisite concerns, where one site could e.g. have chat disabled and another might not. The filtered plugin registers I added will not be included if the plugin is disabled.
This commit is contained in:
Martin Brennan
2022-12-19 13:46:17 +10:00
committed by GitHub
parent 68d5bdefdd
commit 6b9c0ee554
13 changed files with 230 additions and 124 deletions

View File

@ -730,11 +730,11 @@ after_initialize do
register_about_stat_group("chat_users") { Chat::Statistics.about_users }
# Make sure to update spec/system/hashtag_autocomplete_spec.rb when changing this.
register_hashtag_data_source("channel", Chat::ChatChannelHashtagDataSource)
register_hashtag_type_in_context("channel", "chat-composer", 200)
register_hashtag_type_in_context("category", "chat-composer", 100)
register_hashtag_type_in_context("tag", "chat-composer", 50)
register_hashtag_type_in_context("channel", "topic-composer", 10)
register_hashtag_data_source(Chat::ChatChannelHashtagDataSource)
register_hashtag_type_priority_for_context("channel", "chat-composer", 200)
register_hashtag_type_priority_for_context("category", "chat-composer", 100)
register_hashtag_type_priority_for_context("tag", "chat-composer", 50)
register_hashtag_type_priority_for_context("channel", "topic-composer", 10)
Site.markdown_additional_options["chat"] = {
limited_pretty_text_features: ChatMessage::MARKDOWN_FEATURES,