2023-07-13 15:34:02 -04:00
|
|
|
import Component from "@glimmer/component";
|
2023-08-22 13:10:21 -04:00
|
|
|
import { action, computed } from "@ember/object";
|
2023-11-03 07:30:09 -04:00
|
|
|
import { inject as service } from "@ember/service";
|
2023-08-22 13:10:21 -04:00
|
|
|
import I18n from "I18n";
|
2023-07-13 15:34:02 -04:00
|
|
|
|
|
|
|
export default class extends Component {
|
|
|
|
static shouldRender(args) {
|
2023-03-30 18:07:22 -04:00
|
|
|
return (args.model.related_topics?.length || 0) > 0;
|
2023-07-13 15:34:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@service store;
|
2023-07-31 17:33:37 -04:00
|
|
|
@service site;
|
|
|
|
@service moreTopicsPreferenceTracking;
|
|
|
|
|
|
|
|
listId = "related-topics";
|
|
|
|
|
2023-08-22 13:10:21 -04:00
|
|
|
@computed("moreTopicsPreferenceTracking.selectedTab")
|
2023-07-31 17:33:37 -04:00
|
|
|
get hidden() {
|
2023-08-22 13:10:21 -04:00
|
|
|
return this.moreTopicsPreferenceTracking.selectedTab !== this.listId;
|
2023-07-31 17:33:37 -04:00
|
|
|
}
|
2023-07-13 15:34:02 -04:00
|
|
|
|
|
|
|
get relatedTopics() {
|
|
|
|
return this.args.outletArgs.model.related_topics.map((topic) =>
|
|
|
|
this.store.createRecord("topic", topic)
|
|
|
|
);
|
|
|
|
}
|
2023-08-22 13:10:21 -04:00
|
|
|
|
|
|
|
@action
|
|
|
|
registerList() {
|
|
|
|
this.moreTopicsPreferenceTracking.registerTopicList({
|
|
|
|
name: I18n.t("discourse_ai.related_topics.pill"),
|
|
|
|
id: this.listId,
|
2023-10-19 18:31:56 -04:00
|
|
|
icon: "discourse-sparkles",
|
2023-08-22 13:10:21 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
removeList() {
|
|
|
|
this.moreTopicsPreferenceTracking.removeTopicList(this.listId);
|
|
|
|
}
|
2023-07-13 15:34:02 -04:00
|
|
|
}
|