SHA256
UI: обновить экран канала и треда
This commit is contained in:
@@ -209,6 +209,24 @@ function resolveChannelDisplayName(channelSelector) {
|
||||
return `${found.channel?.ownerLogin || 'неизвестно'}/${found.channel?.channelName || 'канал'}`;
|
||||
}
|
||||
|
||||
function resolveChannelHeadingFromNode(node) {
|
||||
const info = node?.channelInfo;
|
||||
const ownerBch = String(info?.ownerBlockchainName || '').trim();
|
||||
const rootBlockNumber = Number(info?.channelRoot?.blockNumber);
|
||||
if (!ownerBch || !Number.isFinite(rootBlockNumber) || rootBlockNumber < 0) return '';
|
||||
if (rootBlockNumber === 0) return 'История пользователя';
|
||||
|
||||
const label = resolveChannelDisplayName({
|
||||
ownerBlockchainName: ownerBch,
|
||||
channelRootBlockNumber: rootBlockNumber,
|
||||
channelRootBlockHash: '0',
|
||||
});
|
||||
const slashIndex = label.indexOf('/');
|
||||
const channelName = slashIndex >= 0 ? label.slice(slashIndex + 1).trim() : label.trim();
|
||||
if (!channelName) return 'Сообщение в канале';
|
||||
return `Сообщение в канале ${channelName}`;
|
||||
}
|
||||
|
||||
function extractChannelContextFromThreadPayload(payload) {
|
||||
const focusInfo = payload?.focus?.channelInfo;
|
||||
if (focusInfo?.ownerBlockchainName && focusInfo?.channelRoot?.blockNumber != null) {
|
||||
@@ -706,7 +724,7 @@ function renderNodeCard(node, heading, handlers, localNumber) {
|
||||
const isOwnMessage = String(node?.authorLogin || '').trim().toLowerCase() === String(state.session.login || '').trim().toLowerCase();
|
||||
const isChannelPost = Number(node?.channelInfo?.channelRoot?.blockNumber) >= 0;
|
||||
const msgSubType = Number(node?.msgSubType || 0);
|
||||
const repostTarget = msgSubType === 30 ? buildRepostTargetFromNode(node) : null;
|
||||
const repostTarget = msgSubType === 50 ? buildRepostTargetFromNode(node) : null;
|
||||
const parsedText = parseMessageAttachments(text);
|
||||
|
||||
const headingText = String(heading || '').trim();
|
||||
@@ -1326,12 +1344,9 @@ export function render({ navigate, route }) {
|
||||
if (ancestors.length) {
|
||||
ancestorsWrap = document.createElement('div');
|
||||
ancestorsWrap.className = 'stack thread-block thread-block--ancestors';
|
||||
const title = document.createElement('h3');
|
||||
title.className = 'section-title';
|
||||
title.textContent = 'История выше (на что это ответ)';
|
||||
ancestorsWrap.append(title);
|
||||
ancestors.forEach((node, index) => {
|
||||
ancestorsWrap.append(renderNodeCard(node, `Предок ${index + 1}`, handlers, nextNumber()));
|
||||
const heading = index === 0 ? resolveChannelHeadingFromNode(node) : '';
|
||||
ancestorsWrap.append(renderNodeCard(node, heading, handlers, nextNumber()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user