Files
David BattersbyandGitHub 35d8d41da7 FIX: improve chat channel sorting for DMs (#30124)
This change sorts unread channels in descending order based on last message date, so channels with the latest activity will always appear at the top. It also adds some improvements for sorting channels with unread threads, now when multiple channels have unread threads, they will be sorted by last thread reply date to ensure more active channels rise to the top.

For DM channels, the order is now:

- Urgent (green badge) - unread messages, mentions and unread watched threads (most recent activity at top)
- Unread (blue badge) - unread tracked threads (most recent thread reply at top)
- Everything else (most recent message at top)
2024-12-05 13:33:55 +04:00

35 lines
902 B
Plaintext

import Component from "@glimmer/component";
import { i18n } from "discourse-i18n";
export default class ChatChannelMetadata extends Component {
get lastMessageFormattedDate() {
const lastMessageDate = this.showThreadUnreadDate
? this.args.channel.lastUnreadThreadDate
: this.args.channel.lastMessage.createdAt;
return moment(lastMessageDate).calendar(null, {
sameDay: "LT",
lastDay: `[${i18n("chat.dates.yesterday")}]`,
lastWeek: "dddd",
sameElse: "l",
});
}
get showThreadUnreadDate() {
return (
this.args.channel.lastUnreadThreadDate >
this.args.channel.lastMessage.createdAt
);
}
<template>
<div class="chat-channel__metadata">
{{#if @channel.lastMessage}}
<div class="chat-channel__metadata-date">
{{this.lastMessageFormattedDate}}
</div>
{{/if}}
</div>
</template>
}