A platform for community discussion. Free, open, simple.
DEV: Remove buffered rendering from navigation-item
Blake Erickson006e5904be80
diff --git a/app/assets/javascripts/discourse/components/navigation-item.js.es6 b/app/assets/javascripts/discourse/components/navigation-item.js.es6index 90c56da1c94..20c76dab1ef 100644--- a/app/assets/javascripts/discourse/components/navigation-item.js.es6+++ b/app/assets/javascripts/discourse/components/navigation-item.js.es6@@ -1,77 +1,69 @@import discourseComputed from "discourse-common/utils/decorators";import Component from "@ember/component";-import { bufferedRender } from "discourse-common/lib/buffered-render";import FilterModeMixin from "discourse/mixins/filter-mode";-export default Component.extend(- FilterModeMixin,- bufferedRender({- tagName: "li",- classNameBindings: [- "active",- "content.hasIcon:has-icon",- "content.classNames",- "hidden"- ],- attributeBindings: ["content.title:title"],- hidden: false,- rerenderTriggers: ["content.count"],+export default Component.extend(FilterModeMixin, {+ tagName: "li",+ classNameBindings: [+ "active",+ "content.hasIcon:has-icon",+ "content.classNames",+ "hidden"+ ],+ attributeBindings: ["content.title:title"],+ hidden: false,+ rerenderTriggers: ["content.count"],+ activeClass: "",+ hrefLink: null,- @discourseComputed("content.filterType", "filterType", "content.active")- active(contentFilterType, filterType, active) {- if (active !== undefined) {- return active;- }- return contentFilterType === filterType;- },+ @discourseComputed("content.filterType", "filterType", "content.active")+ active(contentFilterType, filterType, active) {+ if (active !== undefined) {+ return active;+ }+ return contentFilterType === filterType;+ },- buildBuffer(buffer) {- const content = this.content;+ didReceiveAttrs() {+ this._super(...arguments);+ const content = this.content;- let href = content.get("href");- let queryParams = [];+ let href = content.get("href");+ let queryParams = [];- // Include the category id if the option is present- if (content.get("includeCategoryId")) {- let categoryId = this.get("content.category.id");- if (categoryId) {- queryParams.push(`category_id=${categoryId}`);- }- }-- // ensures we keep discovery query params added through plugin api- if (content.persistedQueryParams) {- Object.keys(content.persistedQueryParams).forEach(key => {- const value = content.persistedQueryParams[key];- queryParams.push(`${key}=${value}`);- });+ // Include the category id if the option is present+ if (content.get("includeCategoryId")) {+ let categoryId = this.get("content.category.id");+ if (categoryId) {+ queryParams.push(`category_id=${categoryId}`);}+ }- if (queryParams.length) {- href += `?${queryParams.join("&")}`;- }+ // ensures we keep discovery query params added through plugin api+ if (content.persistedQueryParams) {+ Object.keys(content.persistedQueryParams).forEach(key => {+ const value = content.persistedQueryParams[key];+ queryParams.push(`${key}=${value}`);+ });+ }- 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);- }+ if (queryParams.length) {+ href += `?${queryParams.join("&")}`;+ }+ this.set("hrefLink", href);- buffer.push(- `<a href='${href}'` + (this.active ? 'class="active"' : "") + `>`- );+ this.set("activeClass", this.active ? "active" : "");- if (content.get("hasIcon")) {- buffer.push("<span class='" + content.get("name") + "'></span>");- }- buffer.push(this.get("content.displayName"));- buffer.push("</a>");+ 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);}- })-);+ }+});diff --git a/app/assets/javascripts/discourse/templates/components/navigation-item.hbs b/app/assets/javascripts/discourse/templates/components/navigation-item.hbsnew file mode 100644index 00000000000..f6ebd1b7867--- /dev/null+++ b/app/assets/javascripts/discourse/templates/components/navigation-item.hbs@@ -0,0 +1,6 @@+<a href={{hrefLink}} class={{activeClass}}>+{{#if hasIcon}}+<span class={{content.name}}></span>+{{/if}}+{{content.displayName}}+</a>