A platform for community discussion. Free, open, simple.
DEV: Convert count-i18n to gjs (#26888)
Jarek Radosz16cd098de98b
diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.gjs b/app/assets/javascripts/discourse/app/components/count-i18n.gjsnew file mode 100644index 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;+ }++ <template>+ <span>{{htmlSafe (i18n this.fullKey count=@count)}}</span>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/count-i18n.hbs b/app/assets/javascripts/discourse/app/components/count-i18n.hbsdeleted file mode 100644index 7c831d8809b..00000000000--- a/app/assets/javascripts/discourse/app/components/count-i18n.hbs+++ /dev/null@@ -1 +0,0 @@-{{this.i18nCount}}\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/count-i18n.js b/app/assets/javascripts/discourse/app/components/count-i18n.jsdeleted file mode 100644index 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.hbsindex 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'}}"><CountI18n- @key="topic_count_"- @suffix="latest"+ @key="topic_count_latest"@count={{or this.model.loadingBefore this.incomingCount}}/>{{#if @model.loadingBefore}}