diff --git a/assets/javascripts/initializers/chat-summary.js b/assets/javascripts/initializers/chat-summary.js index ee53684c..97e78684 100644 --- a/assets/javascripts/initializers/chat-summary.js +++ b/assets/javascripts/initializers/chat-summary.js @@ -29,11 +29,10 @@ function initializeChatChannelSummary(api) { } export default { - name: "discourse_ai-chat_channel_summary", + name: "discourse-ai-chat-channel-summary", initialize(container) { - const settings = container.lookup("site-settings:main"); - + const settings = container.lookup("service:site-settings"); const summarizationEnabled = settings.discourse_ai_enabled && settings.ai_summarization_enabled; diff --git a/assets/javascripts/initializers/composer-ai-helper.js b/assets/javascripts/initializers/composer-ai-helper.js index 57a7a3d1..24c841e3 100644 --- a/assets/javascripts/initializers/composer-ai-helper.js +++ b/assets/javascripts/initializers/composer-ai-helper.js @@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal"; function initializeComposerAIHelper(api) { api.modifyClass("component:composer-editor", { + pluginId: "discourse-ai", + actions: { extraButtons(toolbar) { this._super(toolbar); @@ -48,20 +50,20 @@ function initializeComposerAIHelper(api) { } export default { - name: "discourse_ai-composer-helper", + name: "discourse-ai-composer-helper", initialize(container) { - const settings = container.lookup("site-settings:main"); + const settings = container.lookup("service:site-settings"); const user = container.lookup("service:current-user"); - const helperEnabled = settings.discourse_ai_enabled && settings.composer_ai_helper_enabled; const allowedGroups = settings.ai_helper_allowed_groups .split("|") .map(parseInt); - let canUseAssistant = - user && user.groups.some((g) => allowedGroups.includes(g.id)); + const canUseAssistant = user?.groups.some((g) => + allowedGroups.includes(g.id) + ); if (helperEnabled && canUseAssistant) { withPluginApi("1.6.0", initializeComposerAIHelper); diff --git a/assets/javascripts/initializers/semantic-full-page-search.js b/assets/javascripts/initializers/semantic-full-page-search.js index c8641db9..4db7f979 100644 --- a/assets/javascripts/initializers/semantic-full-page-search.js +++ b/assets/javascripts/initializers/semantic-full-page-search.js @@ -50,11 +50,10 @@ function initializeSemanticSearch(api) { } export default { - name: "discourse_ai-full-page-semantic-search", + name: "discourse-ai-full-page-semantic-search", initialize(container) { - const settings = container.lookup("site-settings:main"); - + const settings = container.lookup("service:site-settings"); const semanticSearch = settings.ai_embeddings_semantic_search_enabled; if (settings.ai_embeddings_enabled && semanticSearch) { diff --git a/assets/javascripts/initializers/topic-summary.js b/assets/javascripts/initializers/topic-summary.js index bcfa33f0..d14a6792 100644 --- a/assets/javascripts/initializers/topic-summary.js +++ b/assets/javascripts/initializers/topic-summary.js @@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal"; function initializeTopicSummary(api) { api.modifyClass("component:scrolling-post-stream", { + pluginId: "discourse-ai", + showAiSummary() { showModal("ai-summary").setProperties({ targetId: this.posts["posts"][0].topic_id, @@ -28,11 +30,10 @@ function initializeTopicSummary(api) { } export default { - name: "discourse_ai-topic_summary", + name: "discourse-ai-topic-summary", initialize(container) { - const settings = container.lookup("site-settings:main"); - + const settings = container.lookup("service:site-settings"); const summarizationEnabled = settings.discourse_ai_enabled && settings.ai_summarization_enabled;