FIX: Rerender related topics correctly when topic changes (#100)
* FIX: Rerender related topics correctly when topic changes Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
This commit is contained in:
parent
5e3f4e1b78
commit
48d880d3c8
|
@ -1,4 +1,4 @@
|
||||||
<div>
|
<div class="related-topics">
|
||||||
<h3 id="related-topics-title" class="related-topics-title">
|
<h3 id="related-topics-title" class="related-topics-title">
|
||||||
{{i18n "discourse_ai.related_topics.title"}}
|
{{i18n "discourse_ai.related_topics.title"}}
|
||||||
</h3>
|
</h3>
|
|
@ -1,15 +1,16 @@
|
||||||
export default {
|
import Component from "@glimmer/component";
|
||||||
shouldRender(args) {
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
|
export default class extends Component {
|
||||||
|
static shouldRender(args) {
|
||||||
return (args.model.related_topics?.length || 0) > 0;
|
return (args.model.related_topics?.length || 0) > 0;
|
||||||
},
|
}
|
||||||
setupComponent(args, component) {
|
|
||||||
if (component.model.related_topics) {
|
@service store;
|
||||||
component.set(
|
|
||||||
"relatedTopics",
|
get relatedTopics() {
|
||||||
component.model.related_topics.map((topic) =>
|
return this.args.outletArgs.model.related_topics.map((topic) =>
|
||||||
this.store.createRecord("topic", topic)
|
this.store.createRecord("topic", topic)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
.related-topics {
|
||||||
|
margin: 4.5em 0 1em;
|
||||||
|
}
|
|
@ -16,6 +16,8 @@ register_asset "stylesheets/modules/ai-helper/common/ai-helper.scss"
|
||||||
|
|
||||||
register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss"
|
register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss"
|
||||||
|
|
||||||
|
register_asset "stylesheets/modules/embeddings/common/semantic-related-topics.scss"
|
||||||
|
|
||||||
module ::DiscourseAi
|
module ::DiscourseAi
|
||||||
PLUGIN_NAME = "discourse-ai"
|
PLUGIN_NAME = "discourse-ai"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue