Revert "DEV: Clean up all message bus subscriptions (#18675)" (#19267)

This reverts commit b0839ccf27.
This commit is contained in:
Jarek Radosz
2022-11-30 16:29:10 +00:00
committed by GitHub
parent 6a389fd15a
commit 49e0fc04f7
21 changed files with 496 additions and 624 deletions
@@ -1,7 +1,7 @@
import EmberObject from "@ember/object";
import WidgetGlue from "discourse/widgets/glue";
import { getRegister } from "discourse-common/lib/get-owner";
import { bind, observes } from "discourse-common/utils/decorators";
import { observes } from "discourse-common/utils/decorators";
import { withPluginApi } from "discourse/lib/plugin-api";
const PLUGIN_ID = "discourse-poll";
@@ -34,19 +34,16 @@ function initializePolls(api) {
subscribe() {
this._super(...arguments);
this.messageBus.subscribe(`/polls/${this.model.id}`, this._onPollMessage);
this.messageBus.subscribe(`/polls/${this.model.id}`, (msg) => {
const post = this.get("model.postStream").findLoadedPost(msg.post_id);
post?.set("polls", msg.polls);
});
},
unsubscribe() {
this.messageBus.unsubscribe("/polls/*", this._onPollMessage);
this.messageBus.unsubscribe("/polls/*");
this._super(...arguments);
},
@bind
_onPollMessage(msg) {
const post = this.get("model.postStream").findLoadedPost(msg.post_id);
post?.set("polls", msg.polls);
},
});
api.modifyClass("model:post", {