FIX: ensures shortcuts work correctly with topic-notifications-button (#8956)

This commit is contained in:
Joffrey JAFFEUX 2020-02-13 10:01:28 +01:00 committed by GitHub
parent 42bda52486
commit 3875785dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 17 deletions

View File

@ -6,11 +6,35 @@ export default Component.extend({
appendReason: true, appendReason: true,
showFullTitle: true, showFullTitle: true,
didInsertElement() {
this._super(...arguments);
this.appEvents.on(
"topic-notifications-button:changed",
this,
"_changeTopicNotificationLevel"
);
},
willDestroyElement() {
this._super(...arguments);
this.appEvents.off(
"topic-notifications-button:changed",
this,
"_changeTopicNotificationLevel"
);
},
_changeTopicNotificationLevel(level) {
if (level.id !== this.notificationLevel) {
this.topic.details.updateNotifications(level.id);
}
},
actions: { actions: {
changeTopicNotificationLevel(newNotificationLevel) { changeTopicNotificationLevel(level, notification) {
if (newNotificationLevel !== this.notificationLevel) { this._changeTopicNotificationLevel(notification);
this.topic.details.updateNotifications(newNotificationLevel);
}
} }
} }
}); });

View File

@ -16,17 +16,5 @@ export default NotificationsButtonComponent.extend({
i18nPostfix: computed("topic.archetype", function() { i18nPostfix: computed("topic.archetype", function() {
return this.topic.archetype === "private_message" ? "_pm" : ""; return this.topic.archetype === "private_message" ? "_pm" : "";
}), })
didInsertElement() {
this._super(...arguments);
this.appEvents.on("topic-notifications-button:changed", this, "onSelect");
},
willDestroyElement() {
this._super(...arguments);
this.appEvents.off("topic-notifications-button:changed", this, "onSelect");
}
}); });