From 2290ec9e87ab005fcb6666c1448bdbe4e7b92bd6 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Wed, 4 Dec 2019 15:34:54 -0700 Subject: [PATCH] DEV: Remove buffered rendering from i18n count This is another refactoring in the multi-step process to remove all uses of our custom Render Buffer. Previous commit: 80f4b9e2279856eb34349636a50a3cc3967ffaf3 in this series. This commit affects the display of translated counts that is used in multiple places like showing how many posts are selected using the select posts feature on a topic. It is just a refactor and does not change any functionality. --- .../discourse/components/count-i18n.js.es6 | 26 +++++++++---------- .../templates/components/count-i18n.hbs | 1 + 2 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 app/assets/javascripts/discourse/templates/components/count-i18n.hbs diff --git a/app/assets/javascripts/discourse/components/count-i18n.js.es6 b/app/assets/javascripts/discourse/components/count-i18n.js.es6 index 9bdb715dc5d..d0fd9bdccbe 100644 --- a/app/assets/javascripts/discourse/components/count-i18n.js.es6 +++ b/app/assets/javascripts/discourse/components/count-i18n.js.es6 @@ -1,17 +1,15 @@ import Component from "@ember/component"; -import { bufferedRender } from "discourse-common/lib/buffered-render"; -export default Component.extend( - bufferedRender({ - tagName: "span", - rerenderTriggers: ["count", "suffix"], +export default Component.extend({ + tagName: "span", + rerenderTriggers: ["count", "suffix"], + i18nCount: null, - buildBuffer(buffer) { - buffer.push( - I18n.t(this.key + (this.suffix || ""), { - count: this.count - }) - ); - } - }) -); + didReceiveAttrs() { + this._super(...arguments); + this.set( + "i18nCount", + I18n.t(this.key + (this.suffix || ""), { count: this.count }).htmlSafe() + ); + } +}); diff --git a/app/assets/javascripts/discourse/templates/components/count-i18n.hbs b/app/assets/javascripts/discourse/templates/components/count-i18n.hbs new file mode 100644 index 00000000000..f7a5927a07a --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/count-i18n.hbs @@ -0,0 +1 @@ +{{i18nCount}}