Skip to content

A platform for community discussion. Free, open, simple.

FIX: Unsubscribe from topic presence when navigating between topics (#12198)

Osama Sayeghbd709c89a729
diff --git a/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6
index 169f00b4385..f38ac5c5822 100644
--- a/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6
+++ b/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6
@@ -6,6 +6,7 @@ import { inject as service } from "@ember/service";
export default Component.extend({
topic: null,
+ topicId: null,
presenceManager: service(),
@discourseComputed("topic.id")
@@ -15,8 +16,17 @@ export default Component.extend({
shouldDisplay: gt("users.length", 0),
+ didReceiveAttrs() {
+ this._super(...arguments);
+ if (this.topicId) {
+ this.presenceManager.unsubscribe(this.topicId, TOPIC_TYPE);
+ }
+ this.set("topicId", this.get("topic.id"));
+ },
+
@on("didInsertElement")
subscribe() {
+ this.set("topicId", this.get("topic.id"));
this.presenceManager.subscribe(this.get("topic.id"), TOPIC_TYPE);
},