mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-09 07:33:30 +00:00
25 lines
735 B
JavaScript
25 lines
735 B
JavaScript
|
import { apiInitializer } from "discourse/lib/api";
|
||
|
import cookie from "discourse/lib/cookie";
|
||
|
|
||
|
export default apiInitializer((api) => {
|
||
|
const settings = api.container.lookup("service:site-settings");
|
||
|
|
||
|
if (!settings.discourse_ai_enabled || !settings.ai_translation_enabled) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
api.registerCustomPostMessageCallback(
|
||
|
"localized",
|
||
|
(topicController, data) => {
|
||
|
if (!cookie("content-localization-show-original")) {
|
||
|
const postStream = topicController.get("model.postStream");
|
||
|
postStream.triggerChangedPost(data.id, data.updated_at).then(() => {
|
||
|
topicController.appEvents.trigger("post-stream:refresh", {
|
||
|
id: data.id,
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
});
|