mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Minor code cleanup (#18225)
Various small changes made while debugging MessageBus-related tests.
This commit is contained in:
@@ -46,21 +46,21 @@ function initialize(api) {
|
||||
subscribe() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.messageBus.subscribe(`/topic/${this.get("model.id")}`, (data) => {
|
||||
this.messageBus.subscribe(`/topic/${this.model.id}`, (data) => {
|
||||
const topic = this.model;
|
||||
|
||||
// scroll only for discobot (-2 is discobot id)
|
||||
if (
|
||||
topic.get("isPrivateMessage") &&
|
||||
topic.isPrivateMessage &&
|
||||
this.currentUser &&
|
||||
this.currentUser.get("id") !== data.user_id &&
|
||||
this.currentUser.id !== data.user_id &&
|
||||
data.user_id === -2 &&
|
||||
data.type === "created"
|
||||
) {
|
||||
const postNumber = data.post_number;
|
||||
const notInPostStream =
|
||||
topic.get("highest_post_number") <= postNumber;
|
||||
const postNumberDifference = postNumber - topic.get("currentPost");
|
||||
const postNumberDifference = postNumber - topic.currentPost;
|
||||
|
||||
if (
|
||||
notInPostStream &&
|
||||
@@ -116,7 +116,7 @@ function initialize(api) {
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "new-user-narratve",
|
||||
name: "new-user-narrative",
|
||||
|
||||
initialize(container) {
|
||||
const siteSettings = container.lookup("service:site-settings");
|
||||
|
||||
@@ -31,15 +31,15 @@ function initializePolls(api) {
|
||||
|
||||
api.modifyClass("controller:topic", {
|
||||
pluginId: PLUGIN_ID,
|
||||
|
||||
subscribe() {
|
||||
this._super(...arguments);
|
||||
this.messageBus.subscribe("/polls/" + this.get("model.id"), (msg) => {
|
||||
this.messageBus.subscribe(`/polls/${this.model.id}`, (msg) => {
|
||||
const post = this.get("model.postStream").findLoadedPost(msg.post_id);
|
||||
if (post) {
|
||||
post.set("polls", msg.polls);
|
||||
}
|
||||
post?.set("polls", msg.polls);
|
||||
});
|
||||
},
|
||||
|
||||
unsubscribe() {
|
||||
this.messageBus.unsubscribe("/polls/*");
|
||||
this._super(...arguments);
|
||||
|
||||
Reference in New Issue
Block a user