2024-10-28 14:15:53 -04:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { service } from "@ember/service";
|
2024-11-19 15:33:34 -05:00
|
|
|
import { htmlSafe } from "@ember/template";
|
|
|
|
import { emojiUnescape, sanitize } from "discourse/lib/text";
|
2024-10-28 14:15:53 -04:00
|
|
|
|
|
|
|
export default class AiTopicGist extends Component {
|
2024-11-19 15:33:34 -05:00
|
|
|
@service gists;
|
2024-10-29 11:59:41 -04:00
|
|
|
|
2024-11-19 15:33:34 -05:00
|
|
|
get shouldShow() {
|
|
|
|
return this.gists.preference === "table-ai" && this.gists.shouldShow;
|
2024-10-29 11:59:41 -04:00
|
|
|
}
|
2024-10-28 14:15:53 -04:00
|
|
|
|
2024-11-19 15:33:34 -05:00
|
|
|
get gistOrExcerpt() {
|
|
|
|
const topic = this.args.topic;
|
|
|
|
const gist = topic.get("ai_topic_gist");
|
|
|
|
const excerpt = emojiUnescape(sanitize(topic.get("excerpt")));
|
|
|
|
|
|
|
|
return gist || excerpt;
|
2024-10-28 14:15:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
<template>
|
2024-11-19 15:33:34 -05:00
|
|
|
{{#if this.shouldShow}}
|
|
|
|
{{#if this.gistOrExcerpt}}
|
|
|
|
<div class="excerpt">
|
|
|
|
<div>{{htmlSafe this.gistOrExcerpt}}</div>
|
2024-10-28 14:15:53 -04:00
|
|
|
</div>
|
2024-11-19 15:33:34 -05:00
|
|
|
{{/if}}
|
2024-10-28 14:15:53 -04:00
|
|
|
{{/if}}
|
|
|
|
</template>
|
|
|
|
}
|