DEV: Remove buffered rendering from topic-post-badges
This is another refactoring in the multi-step process to remove all uses
of our custom Render Buffer.
Previous commit: f5cca4930d
in this
series.
This commit affects the display of some of the unread, new, and unseen
badges in topic lists like when then "show subcategory list above topics
in this category" option is checked.
This commit is contained in:
parent
b6589f203b
commit
ea6326c860
|
@ -1,33 +1,17 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
|
||||||
|
|
||||||
// Creates a link
|
export default Component.extend({
|
||||||
function link(buffer, prop, url, cssClass, i18nKey, text) {
|
tagName: "span",
|
||||||
if (!prop) {
|
classNameBindings: [":topic-post-badges"],
|
||||||
return;
|
rerenderTriggers: ["url", "unread", "newPosts", "unseen"],
|
||||||
|
newDotText: null,
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
this.set(
|
||||||
|
"newDotText",
|
||||||
|
this.currentUser && this.currentUser.trust_level > 0
|
||||||
|
? " "
|
||||||
|
: I18n.t("filters.new.lower_title")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const title = I18n.t("topic." + i18nKey, { count: prop });
|
});
|
||||||
buffer.push(
|
|
||||||
`<a href="${url}" class="badge ${cssClass} badge-notification" title="${title}">${text ||
|
|
||||||
prop}</a>\n`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Component.extend(
|
|
||||||
bufferedRender({
|
|
||||||
tagName: "span",
|
|
||||||
classNameBindings: [":topic-post-badges"],
|
|
||||||
rerenderTriggers: ["url", "unread", "newPosts", "unseen"],
|
|
||||||
|
|
||||||
buildBuffer(buffer) {
|
|
||||||
const newDotText =
|
|
||||||
this.currentUser && this.currentUser.trust_level > 0
|
|
||||||
? " "
|
|
||||||
: I18n.t("filters.new.lower_title");
|
|
||||||
const url = this.url;
|
|
||||||
link(buffer, this.unread, url, "unread", "unread_posts");
|
|
||||||
link(buffer, this.newPosts, url, "new-posts", "new_posts");
|
|
||||||
link(buffer, this.unseen, url, "new-topic", "new", newDotText);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{{#if unread }}
|
||||||
|
<a href='{{url}}' class='badge badge-notification unread' title='{{i18n "topic.unread_posts" count=unread}}'>{{unread}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{#if newPosts}}
|
||||||
|
<a href='{{url}}' class='badge badge-notification new-posts' title='{{i18n "topic.total_unread_posts" count=newPosts}}'>{{newPosts}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{#if unseen}}
|
||||||
|
<a href='{{url}}' class='badge badge-notification new-topic' title='{{i18n "topic.new"}}'>{{newDotText}}</a>
|
||||||
|
{{/if}}
|
Loading…
Reference in New Issue