fix: show date for messages older than today

This commit is contained in:
Markov 2026-03-14 10:04:31 +01:00
parent 7358b05b11
commit ce2bac9b00

View File

@ -310,7 +310,16 @@ export default function ChatPanel({ chatId, projectId }: Props) {
: (msg.author?.name || msg.author?.slug || "Unknown")} : (msg.author?.name || msg.author?.slug || "Unknown")}
</span> </span>
<span>·</span> <span>·</span>
<span>{new Date(msg.created_at).toLocaleString("ru-RU", { hour: "2-digit", minute: "2-digit" })}</span> <span>{(() => {
const d = new Date(msg.created_at);
const now = new Date();
const isToday = d.toDateString() === now.toDateString();
const time = d.toLocaleString("ru-RU", { hour: "2-digit", minute: "2-digit" });
if (isToday) return time;
const yesterday = new Date(now); yesterday.setDate(now.getDate() - 1);
if (d.toDateString() === yesterday.toDateString()) return `вчера, ${time}`;
return d.toLocaleString("ru-RU", { day: "numeric", month: "short" }) + `, ${time}`;
})()}</span>
</div> </div>
{msg.thinking && ( {msg.thinking && (
<details className="ml-5 mb-1"> <details className="ml-5 mb-1">