SHA256
UI: полные счётчики ответов, поле сообщения как в Telegram, переключатель «Связей», шапка
- Счётчик ответов – по всем уровням: обсуждение считает по дереву, лента берёт итог из обсуждения (кэш или фоновая подгрузка видимых записей, они же потом открываются сразу). Сервер пока отдаёт только прямые ответы. - Чат: поле-«таблетка» растёт плавно (высота меряется по скрытой копии, без сброса в auto), смайлик внутри поля справа внизу, «Отправить» 44 px по низу; убраны правила перестройки в две колонки. - «Связи»: фильтры – общий блок-переключатель (.tabs), как на других вкладках, всё помещается. - Шапка: название крупнее и жирнее, подпись под ним компактнее.
This commit is contained in:
@@ -3,7 +3,7 @@ import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { iconHtml } from '../components/ui-icon.js';
|
||||
import { rememberChannelPosition, readChannelPosition, requestReplyEditorOnOpen, restoreChannelPosition } from '../services/channel-view-state.js';
|
||||
import { getPreviousTrackedPath, parseRouteFromPath, toPrettyPath } from '../router.js';
|
||||
import { prefetchThreadPage } from './channel-thread-view.js';
|
||||
import { prefetchThreadPage, threadTotalReplies } from './channel-thread-view.js';
|
||||
import { attachMessageMenu } from '../components/message-menu.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import {
|
||||
@@ -2078,6 +2078,16 @@ function renderPostCard(post, {
|
||||
}
|
||||
});
|
||||
|
||||
// Сервер считает только прямые ответы; полное число по всем уровням берём из обсуждения (кэш или подгрузка).
|
||||
if (Number(post.repliesCount || 0) > 0) {
|
||||
const threadRoute = buildThreadRoute(post, selector);
|
||||
if (threadRoute) {
|
||||
const threadPath = new URL(`/${toPrettyPath(threadRoute)}`, window.location.origin).pathname;
|
||||
card.dataset.threadPath = threadPath;
|
||||
const known = readPageData('thread', threadPath)?.data;
|
||||
if (known) post.repliesCount = threadTotalReplies(known);
|
||||
}
|
||||
}
|
||||
const discussionButton = document.createElement('button');
|
||||
discussionButton.type = 'button';
|
||||
discussionButton.className = 'ui-button channel-action-item channel-action-discussion';
|
||||
@@ -2494,6 +2504,45 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
|
||||
};
|
||||
}
|
||||
|
||||
// Полные счётчики ответов для видимых записей: обсуждения подгружаются по одному (они же потом открываются сразу).
|
||||
function watchReplyTotals(screen) {
|
||||
if (!('IntersectionObserver' in window)) return () => {};
|
||||
let stopped = false;
|
||||
const queue = [];
|
||||
let running = false;
|
||||
const setCount = (card, total) => {
|
||||
card.querySelectorAll('.channel-action-discussion .channel-action-counter, .channel-action-reply .channel-action-counter')
|
||||
.forEach((counter) => { counter.textContent = total ? String(total) : ''; });
|
||||
};
|
||||
const pump = async () => {
|
||||
if (running) return;
|
||||
running = true;
|
||||
while (!stopped && queue.length) {
|
||||
const card = queue.shift();
|
||||
try {
|
||||
const data = await prefetchThreadPage(card.dataset.threadPath);
|
||||
if (!stopped && data && card.isConnected) setCount(card, threadTotalReplies(data));
|
||||
} catch {
|
||||
// Не удалось – остаётся серверный счётчик прямых ответов.
|
||||
}
|
||||
}
|
||||
running = false;
|
||||
};
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (!entry.isIntersecting) return;
|
||||
observer.unobserve(entry.target);
|
||||
queue.push(entry.target);
|
||||
});
|
||||
void pump();
|
||||
}, { rootMargin: '200px 0px' });
|
||||
screen.querySelectorAll('.channel-message-card[data-thread-path]').forEach((card) => observer.observe(card));
|
||||
return () => {
|
||||
stopped = true;
|
||||
observer.disconnect();
|
||||
};
|
||||
}
|
||||
|
||||
// Фоновая подгрузка канала в кэш, чтобы он открывался сразу (вызывается из обхода ленты каналов).
|
||||
export async function prefetchChannelPage(path) {
|
||||
const pathname = new URL(path, window.location.origin).pathname;
|
||||
@@ -3024,7 +3073,7 @@ export function render({ navigate, route, chrome }) {
|
||||
};
|
||||
}
|
||||
clearContent();
|
||||
cleanupSeenTracking = renderBody(screen, navigate, routeKey, apiData, {
|
||||
const stopSeenTracking = renderBody(screen, navigate, routeKey, apiData, {
|
||||
chrome,
|
||||
restorePosition,
|
||||
scrollToMessageOrdinal,
|
||||
@@ -3118,6 +3167,11 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
onSubscribeChannel: (event) => subscribeToChannel(apiData, event),
|
||||
});
|
||||
const stopReplyTotals = watchReplyTotals(screen);
|
||||
cleanupSeenTracking = () => {
|
||||
if (typeof stopSeenTracking === 'function') stopSeenTracking();
|
||||
stopReplyTotals();
|
||||
};
|
||||
};
|
||||
|
||||
refresh = async () => {
|
||||
|
||||
Reference in New Issue
Block a user