From 5054065e81ec40474d30105451e882a3edc9fbc8 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 7 Sep 2017 19:18:27 +0200 Subject: [PATCH] FIX: broken spec --- .../discourse/components/topic-notifications.js.es6 | 12 +++++++++--- .../discourse/components/topic-timeline.js.es6 | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-notifications.js.es6 b/app/assets/javascripts/discourse/components/topic-notifications.js.es6 index 5187ebb0b6d..a1bdc7cbc86 100644 --- a/app/assets/javascripts/discourse/components/topic-notifications.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-notifications.js.es6 @@ -25,7 +25,9 @@ export default DropdownSelectBoxComponent.extend({ _bindGlobalLevelChanged() { this.appEvents.on("topic-notifications-button:changed", (msg) => { if (msg.type === "notification") { - this.set("value", msg.id); + if (this.get("topic.details.notification_level") !== msg.id) { + this.get("topic.details").updateNotifications(msg.id); + } } }); }, @@ -37,7 +39,6 @@ export default DropdownSelectBoxComponent.extend({ @observes("value") _notificationLevelChanged() { - this.get("topic.details").updateNotifications(this.get("value")); this.appEvents.trigger('topic-notifications-button:changed', {type: 'notification', id: this.get("value")}); }, @@ -47,6 +48,11 @@ export default DropdownSelectBoxComponent.extend({ return iconHTML(details.icon, {class: details.key}).htmlSafe(); }, + @observes("topic.details.notification_level") + _content() { + this.set("value", this.get("topic.details.notification_level")); + }, + @computed("topic.details.notification_level", "showFullTitle") generatedHeadertext(notificationLevel, showFullTitle) { if (showFullTitle) { @@ -75,5 +81,5 @@ export default DropdownSelectBoxComponent.extend({ `; }; - }.property(), + }.property() }); diff --git a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 index cc72ba7f2c8..cfa9340e940 100644 --- a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 @@ -84,6 +84,5 @@ export default MountWidget.extend(Docking, { } this.dispatch('topic:current-post-scrolled', 'timeline-scrollarea'); - this.dispatch('topic-notifications-button:changed', 'topic-notifications-button'); } });