discourse-ai/assets/javascripts/discourse/connectors/after-d-editor/composer-open.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

import Component from "@glimmer/component";
import { computed } from "@ember/object";
import { service } from "@ember/service";
import I18n from "discourse-i18n";
export default class extends Component {
@service currentUser;
@service siteSettings;
get composerModel() {
return this.args?.outletArgs?.composer;
}
get renderChatWarning() {
return this.siteSettings.ai_bot_enable_chat_warning;
}
@computed("composerModel.targetRecipients", "composerModel.title")
get aiBotClasses() {
if (
this.composerModel?.title ===
I18n.t("discourse_ai.ai_bot.default_pm_prefix")
) {
return "ai-bot-chat";
} else {
return "ai-bot-pm";
}
}
@computed("composerModel.targetRecipients")
get isAiBotChat() {
if (
this.composerModel &&
this.composerModel.targetRecipients &&
this.currentUser.ai_enabled_chat_bots
) {
2024-01-19 06:51:26 -05:00
let recipients = this.composerModel.targetRecipients.split(",");
return this.currentUser.ai_enabled_chat_bots.any((bot) =>
2024-01-19 06:51:26 -05:00
recipients.any((username) => username === bot.username)
);
}
return false;
}
}