SHA256
UI: полные счётчики ответов, поле сообщения как в Telegram, переключатель «Связей», шапка
- Счётчик ответов – по всем уровням: обсуждение считает по дереву, лента берёт итог из обсуждения (кэш или фоновая подгрузка видимых записей, они же потом открываются сразу). Сервер пока отдаёт только прямые ответы. - Чат: поле-«таблетка» растёт плавно (высота меряется по скрытой копии, без сброса в auto), смайлик внутри поля справа внизу, «Отправить» 44 px по низу; убраны правила перестройки в две колонки. - «Связи»: фильтры – общий блок-переключатель (.tabs), как на других вкладках, всё помещается. - Шапка: название крупнее и жирнее, подпись под ним компактнее.
This commit is contained in:
@@ -677,7 +677,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
const likes = Number(node?.likesCount || 0);
|
||||
const primaryLikes = Number(node?.primaryLikesCount || 0);
|
||||
const shiningLikes = Number(node?.shiningLikesCount || 0);
|
||||
const replies = Number(node?.repliesCount || 0);
|
||||
const replies = replyCountOf(node);
|
||||
const ratings = Number(node?.ratingsCount || 0);
|
||||
const isOwnMessage = Boolean(state.session.isAuthorized && state.session.login) && String(node?.authorLogin || '').trim().toLowerCase() === String(state.session.login).trim().toLowerCase();
|
||||
const msgSubType = Number(node?.msgSubType || 0);
|
||||
@@ -1066,6 +1066,38 @@ function flattenDescendants(items, parent = null, out = []) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// «Всего ответов в ветке»: сервер даёт только прямые ответы (repliesCount), а показывать нужно все уровни.
|
||||
// Незагруженные глубже ветки учитываем по их прямому счётчику – это нижняя оценка.
|
||||
function annotateReplyTotals(branches) {
|
||||
let sum = 0;
|
||||
(Array.isArray(branches) ? branches : []).forEach((branch) => {
|
||||
if (!branch?.node) return;
|
||||
const children = Array.isArray(branch.children) ? branch.children : [];
|
||||
const loadedTotal = annotateReplyTotals(children);
|
||||
const unloaded = Math.max(0, Number(branch.node.repliesCount || 0) - children.length);
|
||||
branch.node.totalReplies = loadedTotal + unloaded;
|
||||
sum += 1 + branch.node.totalReplies;
|
||||
});
|
||||
return sum;
|
||||
}
|
||||
|
||||
function totalRepliesOfPayload(payload) {
|
||||
const descendants = Array.isArray(payload?.descendants) ? payload.descendants : [];
|
||||
const loaded = annotateReplyTotals(descendants);
|
||||
const unloaded = Math.max(0, Number(payload?.focus?.repliesCount || 0) - descendants.length);
|
||||
const total = loaded + unloaded;
|
||||
if (payload?.focus) payload.focus.totalReplies = total;
|
||||
return total;
|
||||
}
|
||||
|
||||
export function threadTotalReplies(data) {
|
||||
return totalRepliesOfPayload(data?.payload);
|
||||
}
|
||||
|
||||
function replyCountOf(node) {
|
||||
return Number(node?.totalReplies ?? node?.repliesCount ?? 0);
|
||||
}
|
||||
|
||||
function nodeKey(node) {
|
||||
return messageRefKey(buildTargetFromNode(node));
|
||||
}
|
||||
@@ -1158,7 +1190,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
finally { if (like.isConnected) like.disabled = false; }
|
||||
});
|
||||
|
||||
const replies = Number(node?.repliesCount || 0);
|
||||
const replies = replyCountOf(node);
|
||||
const reply = document.createElement('button');
|
||||
reply.type = 'button';
|
||||
reply.className = 'channel-action-item thread-comment__reply';
|
||||
@@ -1537,10 +1569,11 @@ const THREAD_PREFETCH_FRESH_MS = 30_000;
|
||||
// Начинает загрузку обсуждения заранее (касание карточки до клика); экран потом подхватит тот же запрос.
|
||||
export function prefetchThreadPage(path) {
|
||||
const pathname = new URL(path, window.location.origin).pathname;
|
||||
if (threadPrefetches.has(pathname) || pageDataAge('thread', pathname) < THREAD_PREFETCH_FRESH_MS) return;
|
||||
if (threadPrefetches.has(pathname)) return threadPrefetches.get(pathname);
|
||||
if (pageDataAge('thread', pathname) < THREAD_PREFETCH_FRESH_MS) return Promise.resolve(readPageData('thread', pathname)?.data || null);
|
||||
const route = parseRouteFromPath(pathname);
|
||||
const sel = route.pageId === 'channel-thread-view' ? parseThreadSelector(route) : null;
|
||||
if (!sel) return;
|
||||
if (!sel) return Promise.resolve(null);
|
||||
const login = state.session.login;
|
||||
const request = loadThreadData(sel, pathname, () => state.session.login === login)
|
||||
.then((data) => {
|
||||
@@ -1550,6 +1583,7 @@ export function prefetchThreadPage(path) {
|
||||
.finally(() => { threadPrefetches.delete(pathname); });
|
||||
request.catch(() => {});
|
||||
threadPrefetches.set(pathname, request);
|
||||
return request;
|
||||
}
|
||||
|
||||
export function render({ navigate, route, chrome }) {
|
||||
@@ -1833,6 +1867,7 @@ export function render({ navigate, route, chrome }) {
|
||||
const ancestors = Array.isArray(payload?.ancestors) ? payload.ancestors : [];
|
||||
const focus = payload?.focus || null;
|
||||
const descendants = Array.isArray(payload?.descendants) ? payload.descendants : [];
|
||||
const totalReplies = totalRepliesOfPayload(payload);
|
||||
const resolvedChannelTitle = resolvedChannelLabel || String(selector?.channel?.ownerBlockchainName || '').trim() || 'неизвестно';
|
||||
const channelOwner = extractLoginFromBlockchainName(selector?.channel?.ownerBlockchainName || focus?.channelInfo?.ownerBlockchainName || selector?.short?.ownerBlockchainName || '');
|
||||
const shortName = String(selector?.short?.channelName || channelSlug).trim();
|
||||
@@ -1947,7 +1982,7 @@ export function render({ navigate, route, chrome }) {
|
||||
listWrap.className = 'thread-block thread-block--replies';
|
||||
const listTitle = document.createElement('h3');
|
||||
listTitle.className = 'thread-section-title';
|
||||
listTitle.textContent = `Комментарии · ${comments.length}`;
|
||||
listTitle.textContent = `Комментарии · ${Math.max(totalReplies, comments.length)}`;
|
||||
listWrap.append(listTitle);
|
||||
|
||||
// Возврат к ответу после перехода по цитате
|
||||
|
||||
Reference in New Issue
Block a user