From 1921538faa08f9b13340bd755ab6da9479c6fe3d Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Wed, 18 Dec 2019 22:22:28 +1100 Subject: [PATCH] FIX: show new/unread button when a new topic or post is created (#8576) There is a problem that if you read all messages, even when a new one arrives, the button on the top is not showing. This is because once the button got `hidden` class, a label under is properly updated, however, the class is not removed. Therefore, I added computed isHidden function which is recalculated when `count` change. --- .../components/navigation-item.js.es6 | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/discourse/components/navigation-item.js.es6 b/app/assets/javascripts/discourse/components/navigation-item.js.es6 index 20c76dab1ef..5a3f172fa72 100644 --- a/app/assets/javascripts/discourse/components/navigation-item.js.es6 +++ b/app/assets/javascripts/discourse/components/navigation-item.js.es6 @@ -8,7 +8,7 @@ export default Component.extend(FilterModeMixin, { "active", "content.hasIcon:has-icon", "content.classNames", - "hidden" + "isHidden:hidden" ], attributeBindings: ["content.title:title"], hidden: false, @@ -24,6 +24,18 @@ export default Component.extend(FilterModeMixin, { return contentFilterType === filterType; }, + @discourseComputed("content.count") + isHidden(count) { + return ( + !this.active && + this.currentUser && + this.currentUser.trust_level > 0 && + (this.content.get("name") === "new" || + this.content.get("name") === "unread") && + count < 1 + ); + }, + didReceiveAttrs() { this._super(...arguments); const content = this.content; @@ -53,17 +65,5 @@ export default Component.extend(FilterModeMixin, { this.set("hrefLink", href); this.set("activeClass", this.active ? "active" : ""); - - if ( - !this.active && - this.currentUser && - this.currentUser.trust_level > 0 && - (content.get("name") === "new" || content.get("name") === "unread") && - content.get("count") < 1 - ) { - this.set("hidden", true); - } else { - this.set("hidden", false); - } } });