From 3875785dccae130d4e8ffa254870074dd9d96a48 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 13 Feb 2020 10:01:28 +0100 Subject: [PATCH] FIX: ensures shortcuts work correctly with topic-notifications-button (#8956) --- .../topic-notifications-button.js.es6 | 32 ++++++++++++++++--- .../topic-notifications-options.js.es6 | 14 +------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/select-kit/components/topic-notifications-button.js.es6 b/app/assets/javascripts/select-kit/components/topic-notifications-button.js.es6 index efca6b77c8a..3ed6530b917 100644 --- a/app/assets/javascripts/select-kit/components/topic-notifications-button.js.es6 +++ b/app/assets/javascripts/select-kit/components/topic-notifications-button.js.es6 @@ -6,11 +6,35 @@ export default Component.extend({ appendReason: 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: { - changeTopicNotificationLevel(newNotificationLevel) { - if (newNotificationLevel !== this.notificationLevel) { - this.topic.details.updateNotifications(newNotificationLevel); - } + changeTopicNotificationLevel(level, notification) { + this._changeTopicNotificationLevel(notification); } } }); diff --git a/app/assets/javascripts/select-kit/components/topic-notifications-options.js.es6 b/app/assets/javascripts/select-kit/components/topic-notifications-options.js.es6 index a1f98fa6b57..ae3dd483175 100644 --- a/app/assets/javascripts/select-kit/components/topic-notifications-options.js.es6 +++ b/app/assets/javascripts/select-kit/components/topic-notifications-options.js.es6 @@ -16,17 +16,5 @@ export default NotificationsButtonComponent.extend({ i18nPostfix: computed("topic.archetype", function() { 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"); - } + }) });