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.
This commit is contained in:
Krzysztof Kotlarek 2019-12-18 22:22:28 +11:00 committed by David Taylor
parent 3b7f5db5ba
commit 1921538faa

View File

@ -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);
}
}
});