From 16cd098de98bc658abb12e7915760fa4bbd21219 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 6 May 2024 21:03:39 +0200 Subject: [PATCH] DEV: Convert count-i18n to gjs (#26888) --- .../discourse/app/components/count-i18n.gjs | 26 +++++++++++++++++++ .../discourse/app/components/count-i18n.hbs | 1 - .../discourse/app/components/count-i18n.js | 21 --------------- .../app/templates/user-topics-list.hbs | 3 +-- 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 app/assets/javascripts/discourse/app/components/count-i18n.gjs delete mode 100644 app/assets/javascripts/discourse/app/components/count-i18n.hbs delete mode 100644 app/assets/javascripts/discourse/app/components/count-i18n.js diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.gjs b/app/assets/javascripts/discourse/app/components/count-i18n.gjs new file mode 100644 index 00000000000..ca5a2ee98ee --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/count-i18n.gjs @@ -0,0 +1,26 @@ +import Component from "@glimmer/component"; +import { service } from "@ember/service"; +import { htmlSafe } from "@ember/template"; +import i18n from "discourse-common/helpers/i18n"; + +export default class CountI18n extends Component { + @service currentUser; + + get fullKey() { + let key = this.args.key; + + if (this.args.suffix) { + key += this.args.suffix; + } + + if (this.currentUser?.new_new_view_enabled && key === "topic_count_new") { + key = "topic_count_latest"; + } + + return key; + } + + +} diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.hbs b/app/assets/javascripts/discourse/app/components/count-i18n.hbs deleted file mode 100644 index 7c831d8809b..00000000000 --- a/app/assets/javascripts/discourse/app/components/count-i18n.hbs +++ /dev/null @@ -1 +0,0 @@ -{{this.i18nCount}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.js b/app/assets/javascripts/discourse/app/components/count-i18n.js deleted file mode 100644 index 265c7a989c1..00000000000 --- a/app/assets/javascripts/discourse/app/components/count-i18n.js +++ /dev/null @@ -1,21 +0,0 @@ -import Component from "@ember/component"; -import { htmlSafe } from "@ember/template"; -import I18n from "discourse-i18n"; - -export default Component.extend({ - tagName: "span", - i18nCount: null, - - didReceiveAttrs() { - this._super(...arguments); - - let fullKey = this.key + (this.suffix || ""); - if ( - this.currentUser?.new_new_view_enabled && - fullKey === "topic_count_new" - ) { - fullKey = "topic_count_latest"; - } - this.set("i18nCount", htmlSafe(I18n.t(fullKey, { count: this.count }))); - }, -}); diff --git a/app/assets/javascripts/discourse/app/templates/user-topics-list.hbs b/app/assets/javascripts/discourse/app/templates/user-topics-list.hbs index e6e7a473057..4c27fa277af 100644 --- a/app/assets/javascripts/discourse/app/templates/user-topics-list.hbs +++ b/app/assets/javascripts/discourse/app/templates/user-topics-list.hbs @@ -36,8 +36,7 @@ {{if this.model.loadingBefore 'loading'}}" > {{#if @model.loadingBefore}}