mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:23:17 -05:00
PERF: Move user-tips and narrative to per-user messagebus channels (#19773)
Using a shared channel with per-message permissions means that every client is updated with the channel's 'last_id', even if there are no messages available to them. Per-user channel names avoid this problem - the last_id will only be incremented when there is a message for the given user.
This commit is contained in:
+9
-7
@@ -15,9 +15,9 @@ export default {
|
||||
this.appEvents = container.lookup("service:app-events");
|
||||
|
||||
withPluginApi("0.8.7", (api) => {
|
||||
const currentUser = api.getCurrentUser();
|
||||
this.currentUser = api.getCurrentUser();
|
||||
|
||||
if (!currentUser) {
|
||||
if (!this.currentUser) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,17 +41,19 @@ export default {
|
||||
);
|
||||
|
||||
this.messageBus.subscribe(
|
||||
"/new_user_narrative/tutorial_search",
|
||||
`/new_user_narrative/tutorial_search/${this.currentUser.id}`,
|
||||
this.onMessage
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
teardown() {
|
||||
this.messageBus?.unsubscribe(
|
||||
"/new_user_narrative/tutorial_search",
|
||||
this.onMessage
|
||||
);
|
||||
if (this.currentUser) {
|
||||
this.messageBus?.unsubscribe(
|
||||
`/new_user_narrative/tutorial_search/${this.currentUser.id}`,
|
||||
this.onMessage
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@bind
|
||||
|
||||
@@ -173,7 +173,11 @@ module DiscourseNarrativeBot
|
||||
topic = @post.topic
|
||||
post = topic.first_post
|
||||
|
||||
MessageBus.publish("/new_user_narrative/tutorial_search", {}, user_ids: [@user.id])
|
||||
MessageBus.publish(
|
||||
"/new_user_narrative/tutorial_search/#{@user.id}",
|
||||
{},
|
||||
user_ids: [@user.id],
|
||||
)
|
||||
|
||||
raw = <<~MD
|
||||
#{post.raw}
|
||||
|
||||
Reference in New Issue
Block a user