mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: prevents registering multiple topic-notifications-button:changed (#9356)
A large topic page will always have the bottom tracking button, and will also have the timeline, meaning we already had 2 tracking events. But it gets even worse when you know that the timeline button is a component connector which will trigger `didInsertElement` very frequently, meaning we were constantly adding more and more appEvents handlers.
This commit is contained in:
@@ -388,7 +388,8 @@ createWidget("timeline-footer-controls", {
|
||||
topic,
|
||||
showFullTitle: false,
|
||||
appendReason: false,
|
||||
placement: "bottom-end"
|
||||
placement: "bottom-end",
|
||||
mountedAsWidget: true
|
||||
},
|
||||
["notificationLevel"]
|
||||
)
|
||||
|
||||
@@ -10,21 +10,25 @@ export default Component.extend({
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.appEvents.on(
|
||||
"topic-notifications-button:changed",
|
||||
this,
|
||||
"_changeTopicNotificationLevel"
|
||||
);
|
||||
if (!this.mountedAsWidget) {
|
||||
this.appEvents.on(
|
||||
"topic-notifications-button:changed",
|
||||
this,
|
||||
"_changeTopicNotificationLevel"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.appEvents.off(
|
||||
"topic-notifications-button:changed",
|
||||
this,
|
||||
"_changeTopicNotificationLevel"
|
||||
);
|
||||
if (!this.mountedAsWidget) {
|
||||
this.appEvents.off(
|
||||
"topic-notifications-button:changed",
|
||||
this,
|
||||
"_changeTopicNotificationLevel"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_changeTopicNotificationLevel(level) {
|
||||
|
||||
Reference in New Issue
Block a user