DEV: Convert topic-post-badges to glimmer/gjs (#26760)

This commit is contained in:
Jarek Radosz
2024-04-26 16:16:32 +02:00
committed by GitHub
parent e7f0aa52fa
commit 9874801f94
3 changed files with 37 additions and 34 deletions

View File

@@ -0,0 +1,37 @@
import Component from "@glimmer/component";
import { service } from "@ember/service";
import i18n from "discourse-common/helpers/i18n";
export default class TopicPostBadges extends Component {
@service currentUser;
get displayUnreadPosts() {
return this.args.newPosts || this.args.unreadPosts;
}
get newDotText() {
return this.currentUser?.trust_level > 0
? " "
: i18n("filters.new.lower_title");
}
<template>
<span class="topic-post-badges">
{{~#if this.displayUnreadPosts~}}
&nbsp;<a
href={{@url}}
title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}}
class="badge badge-notification unread-posts"
>{{this.displayUnreadPosts}}</a>
{{/if~}}
{{~#if @unseen~}}
&nbsp;<a
href={{@url}}
title={{i18n "topic.new"}}
class="badge badge-notification new-topic"
>{{this.newDotText}}</a>
{{/if~}}
</span>
</template>
}

View File

@@ -1,12 +0,0 @@
{{~#if this.displayUnreadPosts}}&nbsp;<a
href={{this.url}}
title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}}
class="badge badge-notification unread-posts"
>{{this.displayUnreadPosts}}</a>
{{/if~}}
{{~#if this.unseen}}&nbsp;<a
href={{this.url}}
title={{i18n "topic.new"}}
class="badge badge-notification new-topic"
>{{this.newDotText}}</a>
{{/if~}}

View File

@@ -1,22 +0,0 @@
import Component from "@ember/component";
import { or } from "@ember/object/computed";
import I18n from "discourse-i18n";
export default Component.extend({
tagName: "span",
classNameBindings: [":topic-post-badges"],
newDotText: null,
init() {
this._super(...arguments);
this.set(
"newDotText",
this.currentUser && this.currentUser.trust_level > 0
? " "
: I18n.t("filters.new.lower_title")
);
},
displayUnreadPosts: or("newPosts", "unreadPosts"),
});