0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-15 17:24:47 +08:00
discourse/plugins/chat/assets/javascripts/discourse/components/chat-thread-participants.gjs
Joffrey JAFFEUX 09277bc543
FEATURE: my threads page (#24771)
This commit adds a new "My threads" link in sidebar and drawer. This link will open the "/chat/threads" page which contains all threads where the current user is a member. It's ordered by activity (unread and then last message created).

Moreover, the threads list of a channel page is now showing every threads of a channel, and not just the ones where you are a member.
2023-12-11 07:38:07 +01:00

65 lines
1.7 KiB
Text
Vendored

import Component from "@glimmer/component";
import I18n from "discourse-i18n";
import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar";
export default class ChatThreadParticipants extends Component {
get showParticipants() {
if (!this.args.thread) {
return;
}
if (this.includeOriginalMessageUser) {
return this.participantsUsers.length > 1;
}
return this.participantsUsers.length > 0;
}
get includeOriginalMessageUser() {
return this.args.includeOriginalMessageUser ?? true;
}
get participantsUsers() {
const users = this.args.thread.preview.participantUsers;
if (this.includeOriginalMessageUser) {
if (users.length > 3) {
return users.slice(0, 2).concat(users[users.length - 1]);
} else {
return users;
}
}
return users.filter((user) => {
return user.id !== this.args.thread.originalMessage.user.id;
});
}
get otherCountLabel() {
return I18n.t("chat.thread.participants_other_count", {
count: this.args.thread.preview.otherParticipantCount,
});
}
<template>
{{#if this.showParticipants}}
<div class="chat-thread-participants" ...attributes>
<div class="chat-thread-participants__avatar-group">
{{#each this.participantsUsers as |user|}}
<ChatUserAvatar
@user={{user}}
@avatarSize="tiny"
@showPresence={{false}}
@interactive={{false}}
/>
{{/each}}
</div>
{{#if @thread.preview.otherParticipantCount}}
<div class="chat-thread-participants__other-count">
{{this.otherCountLabel}}
</div>
{{/if}}
</div>
{{/if}}
</template>
}