diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs index e628c932e87..681c472b8c0 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs @@ -3,7 +3,11 @@ import { i18n } from "discourse-i18n"; export default class ChatChannelMetadata extends Component { get lastMessageFormattedDate() { - return moment(this.args.channel.lastMessage.createdAt).calendar(null, { + 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", @@ -11,6 +15,13 @@ export default class ChatChannelMetadata extends Component { }); } + get showThreadUnreadDate() { + return ( + this.args.channel.lastUnreadThreadDate > + this.args.channel.lastMessage.createdAt + ); + } +