fixed image and name chat

This commit is contained in:
SlimusMinus
2026-08-13 00:37:41 +03:00
parent 6b1b41d423
commit 66ff0dc5bf
6 changed files with 70 additions and 13 deletions

View File

@@ -24,11 +24,19 @@ export function sortMessages(messages) {
});
}
/** Текст последнего сообщения. Бэкенд отдаёт lastMessage и строкой, и объектом — поддерживаем оба. */
export function getLastMessageText(chat) {
const lm = chat?.lastMessage;
if (typeof lm === "string") return lm;
return lm?.content || "";
}
export function getChatDisplayInfo(chat, post, unreadMap, t) {
const title = post?.title || chat.otherUser?.name || t('chat.user');
const title = post?.title || chat.otherUserName || chat.otherUser?.name || t('chat.user');
const imgSrc = getImageUrl(post?.images?.[0]);
const emoji = post?.emoji;
const unreadCount = unreadMap[chat.id] ?? chat.unreadCount ?? chat.unreadMessages ?? 0;
const preview = getLastMessageText(chat) || t('chat.noMessages');
return { title, imgSrc, emoji, unreadCount };
return { title, imgSrc, emoji, unreadCount, preview };
}