FIX: Show related topics when scrolling long topics (#111)

* FIX: Show related topics when scrolling long topics

* Update assets/javascripts/initializers/related-topics.js

Co-authored-by: Roman Rizzi <roman@discourse.org>

---------

Co-authored-by: Roman Rizzi <roman@discourse.org>
This commit is contained in:
Rafael dos Santos Silva 2023-07-19 19:19:38 -03:00 committed by GitHub
parent e3b4a73267
commit f34094f6cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import { withPluginApi } from "discourse/lib/plugin-api";
export default {
name: "discourse-ai-related-topics",
initialize(container) {
const settings = container.lookup("service:site-settings");
if (settings.ai_embeddings_semantic_related_topics_enabled) {
withPluginApi("1.1.0", (api) => {
api.modifyClass("model:post-stream", {
pluginId: "discourse-ai",
_setSuggestedTopics(result) {
this._super(...arguments);
if (!result.related_topics) {
return;
}
this.topic.setProperties({
related_topics: result.related_topics,
});
},
});
});
}
},
};