Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 9c98cd0

Browse files
committed
event
1 parent feb3303 commit 9c98cd0

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

app/jobs/regular/detect_translate_post.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def execute(args)
4444
)
4545
end
4646
end
47+
48+
MessageBus.publish("/topic/#{post.topic_id}", type: :localized, id: post.id)
4749
end
4850
end
4951
end

app/jobs/regular/detect_translate_topic.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def execute(args)
4242
)
4343
end
4444
end
45+
46+
MessageBus.publish("/topic/#{topic.id}", type: :localized, id: 1)
4547
end
4648
end
4749
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { apiInitializer } from "discourse/lib/api";
2+
import cookie from "discourse/lib/cookie";
3+
4+
export default apiInitializer((api) => {
5+
const settings = api.container.lookup("service:site-settings");
6+
7+
if (!settings.discourse_ai_enabled || !settings.ai_translation_enabled) {
8+
return;
9+
}
10+
11+
api.registerCustomPostMessageCallback(
12+
"localized",
13+
(topicController, data) => {
14+
if (!cookie("content-localization-show-original")) {
15+
const postStream = topicController.get("model.postStream");
16+
postStream.triggerChangedPost(data.id, data.updated_at).then(() => {
17+
topicController.appEvents.trigger("post-stream:refresh", {
18+
id: data.id,
19+
});
20+
});
21+
}
22+
}
23+
);
24+
});

0 commit comments

Comments
 (0)