Refine direct message profile data

This commit is contained in:
AidarKC
2026-09-02 14:56:33 +04:00
parent 065616a18b
commit 1373283947
5 changed files with 77 additions and 29 deletions
+15 -2
View File
@@ -52,6 +52,18 @@ function cleanChannelMessagePreview(text) {
|| (parsed.attachments.length ? 'Вложение' : 'Ждем ваших начинаний');
}
// Keep the channel-list preview tolerant to small API naming changes. The current
// server uses lastMessage.text/createdAtMs; legacy/alternate payloads are accepted
// so the third line (last message + time) does not silently disappear.
function resolveChannelLastMessage(summary) {
const row = summary?.lastMessage || summary?.latestMessage || summary?.last_message || null;
if (!row || typeof row !== 'object') return { text: '', createdAtMs: 0 };
return {
text: String(row.text ?? row.messageText ?? row.preview ?? row.body ?? '').trim(),
createdAtMs: Number(row.createdAtMs ?? row.timeMs ?? row.created_at_ms ?? 0),
};
}
function isChannelsDemoMode() {
try {
const qs = new URLSearchParams(window.location.search);
@@ -719,6 +731,7 @@ function mapApiChannelRow(summary, bucketKey, idx, index, notificationsState) {
const isOwn = bucketKey === 'own';
const title = displayTitle || channelName;
const technicalLabel = `${ownerLogin} / ${channelName}`;
const lastMessage = resolveChannelLastMessage(summary);
return {
id: rowId,
@@ -737,10 +750,10 @@ function mapApiChannelRow(summary, bucketKey, idx, index, notificationsState) {
channelDescription,
channelTypeCode,
channelTypeVersion,
messagePreview: cleanChannelMessagePreview(summary?.lastMessage?.text),
messagePreview: cleanChannelMessagePreview(lastMessage.text),
messagesCount: Number(summary?.messagesCount || 0),
unreadCount: Number(summary?.unreadCount || 0),
lastMessageAt: Number(summary?.lastMessage?.createdAtMs || 0),
lastMessageAt: Number(lastMessage.createdAtMs || 0),
isOwnChannel: isOwn,
isSubscribed: !isOwn,
notificationsEnabled: notificationsState[rowId] === true,
@@ -116,9 +116,6 @@ export async function loadProfileSnapshot(login) {
});
}
const firstName = String(fields.find((field) => field.key === 'first_name')?.value || '').trim();
const lastName = String(fields.find((field) => field.key === 'last_name')?.value || '').trim();
const latestAccountRole = loadLatestByAliasesFromItems(items, ['account_role']);
const rawAccountRole = String(latestAccountRole?.value || '').trim().toLowerCase();
const accountRole = rawAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY || rawAccountRole === PROFILE_ACCOUNT_ROLE_NON_VOTING
@@ -160,8 +157,6 @@ export async function loadProfileSnapshot(login) {
return {
fields,
firstName,
lastName,
toggles,
accountRole,
accountRoleTimeMs: latestAccountRole?.timeMs || 0,
+32
View File
@@ -10759,3 +10759,35 @@ body.chat-topbar-overlay .page-header.app-topbar-shell .header-center {
font-weight: 500;
color: rgba(189,207,232,0.72);
}
/* ===== DM header regression fix (2026-09-02) =====
* The peer identity button intentionally spans the whole free header area.
* Its avatar uses a 119% glass overlay, so neither the center cell nor the
* button may clip overflow. Text keeps its own ellipsis boundary instead.
*/
body.chat-topbar-overlay .page-header.app-topbar-shell .header-center {
overflow: visible !important;
}
.chat-header-peer-btn {
overflow: visible !important;
padding-inline: 2px !important;
}
.chat-header-peer-btn .chat-header-avatar-slot {
width: 44px !important;
height: 44px !important;
min-width: 44px !important;
min-height: 44px !important;
flex: 0 0 44px !important;
overflow: visible !important;
}
.chat-header-peer-btn .chat-header-avatar-slot .chat-header-avatar {
overflow: visible !important;
}
.chat-header-peer-text {
flex: 1 1 auto;
overflow: hidden;
}