fixed image and name chat
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
Reference in New Issue
Block a user