SHA256
UI: каналы и обсуждения в раскладке Threads
Лента канала: у записи аватар и название канала слева сверху, возраст записи («5 мин», «2 ч», «3 д») и «⋯» в шапке, текст и действия колонкой под названием, порядок действий – лайк, обсуждение, поделиться. Обсуждение: открытая запись с шапкой канала и крупным текстом; ответы деревом – под каждым ответом его ветка со сдвигом и линией от аватара, ответ на ответ помечен адресатом, если идёт не сразу после него; в ветке видно два ответа, остальные по «Ещё N ответов». Дерево грузится на 8 уровней вместо 2 (раньше ответы глубже второго уровня не показывались), что глубже – кнопкой открывается обсуждением этого ответа.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.18.0
|
client.version=1.18.1
|
||||||
server.version=1.14.0
|
server.version=1.14.0
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@
|
|||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
window.__SHINE_BUILD_HASH__ = '20261010170500';
|
window.__SHINE_BUILD_HASH__ = '20261011201500';
|
||||||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
animatePress,
|
animatePress,
|
||||||
createSkeletonCard,
|
createSkeletonCard,
|
||||||
formatPostStamp,
|
formatPostStamp,
|
||||||
|
formatShortAge,
|
||||||
formatRelativeTime,
|
formatRelativeTime,
|
||||||
longPressFeel,
|
longPressFeel,
|
||||||
shareOrCopyLink,
|
shareOrCopyLink,
|
||||||
@@ -658,7 +659,7 @@ function openEditMessageModal({ initialText = '', allowEmptyText = false, onSave
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderNodeCard(node, heading, handlers, localNumber, { focusPost = false, channelOwnerBlockchainName = '' } = {}) {
|
function renderNodeCard(node, heading, handlers, localNumber, { focusPost = false, channelOwnerBlockchainName = '', channel = null } = {}) {
|
||||||
const card = document.createElement('article');
|
const card = document.createElement('article');
|
||||||
card.className = 'card stack thread-node-card channel-message-card';
|
card.className = 'card stack thread-node-card channel-message-card';
|
||||||
const isOwnerPost = focusPost && channelOwnerBlockchainName
|
const isOwnerPost = focusPost && channelOwnerBlockchainName
|
||||||
@@ -736,7 +737,26 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
|||||||
if (node?.createdAtMs) timestamp.title = new Date(node.createdAtMs).toLocaleString('ru-RU');
|
if (node?.createdAtMs) timestamp.title = new Date(node.createdAtMs).toLocaleString('ru-RU');
|
||||||
authorBlock.append(title, timestamp);
|
authorBlock.append(title, timestamp);
|
||||||
authorTile.append(avatar, authorBlock);
|
authorTile.append(avatar, authorBlock);
|
||||||
if (isOwnerPost) authorTile.hidden = true;
|
// Запись канала в обсуждении – как открытый пост в Threads: аватар и название канала в шапке, текст на всю ширину.
|
||||||
|
const threadsLayout = isOwnerPost && Boolean(channel);
|
||||||
|
if (isOwnerPost) authorTile.hidden = !threadsLayout;
|
||||||
|
if (threadsLayout) {
|
||||||
|
card.classList.add('channel-message-card--threads', 'channel-message-card--threads-focus');
|
||||||
|
const title = String(channel.title || author).trim();
|
||||||
|
const channelAvatar = renderAvatar({
|
||||||
|
initials: (title[0] || 'К').toUpperCase(),
|
||||||
|
avatar: (channel.avatarAr || channel.avatarSha256) ? { ar: channel.avatarAr, sha256Hex: channel.avatarSha256 } : null,
|
||||||
|
authorLogin: author,
|
||||||
|
size: 'xl',
|
||||||
|
className: 'channel-profile-avatar channel-message-avatar',
|
||||||
|
title,
|
||||||
|
alt: 'Аватар канала',
|
||||||
|
});
|
||||||
|
channelAvatar.style.setProperty('--channel-avatar-size', '36px');
|
||||||
|
avatar.replaceWith(channelAvatar);
|
||||||
|
loginEl.textContent = title;
|
||||||
|
if (node?.createdAtMs) timestamp.textContent = formatShortAge(node.createdAtMs);
|
||||||
|
}
|
||||||
headRow.append(authorTile);
|
headRow.append(authorTile);
|
||||||
const typeMeta = getChannelMessageTypeMeta(node?.msgSubType);
|
const typeMeta = getChannelMessageTypeMeta(node?.msgSubType);
|
||||||
if (typeMeta) {
|
if (typeMeta) {
|
||||||
@@ -909,7 +929,8 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
|||||||
else handlers.onOpenThread(target);
|
else handlers.onOpenThread(target);
|
||||||
});
|
});
|
||||||
// Тот же вид и порядок кнопок, что в ленте канала.
|
// Тот же вид и порядок кнопок, что в ленте канала.
|
||||||
actions.append(likeButton, shareButton, discussionButton);
|
if (threadsLayout) actions.append(likeButton, discussionButton, shareButton);
|
||||||
|
else actions.append(likeButton, shareButton, discussionButton);
|
||||||
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||||
if (repostTarget) {
|
if (repostTarget) {
|
||||||
const originalButton = document.createElement('button');
|
const originalButton = document.createElement('button');
|
||||||
@@ -988,7 +1009,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
|||||||
}
|
}
|
||||||
if (versionsTotal > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions: versions }) });
|
if (versionsTotal > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions: versions }) });
|
||||||
attachMessageMenu(card, headRow, menuItems);
|
attachMessageMenu(card, headRow, menuItems);
|
||||||
if (isOwnerPost) {
|
if (isOwnerPost && !threadsLayout) {
|
||||||
const meta = document.createElement('div');
|
const meta = document.createElement('div');
|
||||||
meta.className = 'channel-message-meta';
|
meta.className = 'channel-message-meta';
|
||||||
const moreButton = headRow.querySelector('.channel-message-more');
|
const moreButton = headRow.querySelector('.channel-message-more');
|
||||||
@@ -1065,7 +1086,9 @@ function renderThreadContext(node, { onOpenPost, onNavigate }) {
|
|||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
// Ответ в обсуждении в раскладке Threads: аватар слева, имя и время сверху, «⋯» справа, под текстом – лайк и ответ.
|
||||||
|
// nested – ответ внутри ветки (меньший аватар, линия от родителя); mention – показать, кому ответ, если это не предыдущий в ветке.
|
||||||
|
function renderComment({ node, parent, focus, channelOwner, handlers, nested = false, mention = false }) {
|
||||||
const target = buildTargetFromNode(node);
|
const target = buildTargetFromNode(node);
|
||||||
const key = messageRefKey(target);
|
const key = messageRefKey(target);
|
||||||
const author = String(node?.authorLogin || 'автор');
|
const author = String(node?.authorLogin || 'автор');
|
||||||
@@ -1074,50 +1097,52 @@ function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
|||||||
const isOwn = Boolean(state.session.login) && author.toLowerCase() === String(state.session.login).toLowerCase();
|
const isOwn = Boolean(state.session.login) && author.toLowerCase() === String(state.session.login).toLowerCase();
|
||||||
|
|
||||||
const item = document.createElement('article');
|
const item = document.createElement('article');
|
||||||
item.className = 'thread-comment channel-message-card';
|
item.className = `thread-comment channel-message-card${nested ? ' thread-comment--nested' : ''}`;
|
||||||
if (key) item.dataset.messageKey = key;
|
if (key) item.dataset.messageKey = key;
|
||||||
|
|
||||||
const person = document.createElement('div');
|
|
||||||
person.className = 'thread-comment__person';
|
|
||||||
const who = document.createElement('button');
|
const who = document.createElement('button');
|
||||||
who.type = 'button';
|
who.type = 'button';
|
||||||
who.className = 'thread-comment__who';
|
who.className = 'thread-comment__who';
|
||||||
who.append(renderUserAvatar({ login: author, size: 'xs', className: 'thread-comment__avatar' }));
|
who.setAttribute('aria-label', `Профиль ${author}`);
|
||||||
const name = document.createElement('span');
|
who.append(renderUserAvatar({ login: author, size: nested ? 'xs' : 'sm', className: 'thread-comment__avatar' }));
|
||||||
|
who.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
||||||
|
|
||||||
|
const main = document.createElement('div');
|
||||||
|
main.className = 'thread-comment__main';
|
||||||
|
|
||||||
|
const head = document.createElement('div');
|
||||||
|
head.className = 'thread-comment__head';
|
||||||
|
const name = document.createElement('button');
|
||||||
|
name.type = 'button';
|
||||||
name.className = 'thread-comment__name';
|
name.className = 'thread-comment__name';
|
||||||
name.textContent = author;
|
name.textContent = author;
|
||||||
who.append(name);
|
name.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
||||||
who.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
head.append(name);
|
||||||
person.append(who);
|
|
||||||
if (channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
|
if (channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
|
||||||
const badge = document.createElement('span');
|
const badge = document.createElement('span');
|
||||||
badge.className = 'thread-comment__badge';
|
badge.className = 'thread-comment__badge';
|
||||||
badge.textContent = 'Автор';
|
badge.textContent = 'Автор';
|
||||||
person.append(badge);
|
head.append(badge);
|
||||||
}
|
}
|
||||||
const time = document.createElement('time');
|
const time = document.createElement('time');
|
||||||
time.textContent = formatPostStamp(node?.createdAtMs);
|
time.textContent = formatShortAge(node?.createdAtMs);
|
||||||
if (node?.createdAtMs) time.title = new Date(node.createdAtMs).toLocaleString('ru-RU');
|
if (node?.createdAtMs) time.title = new Date(node.createdAtMs).toLocaleString('ru-RU');
|
||||||
person.append(time);
|
head.append(time);
|
||||||
item.append(person);
|
main.append(head);
|
||||||
|
|
||||||
// Ответ на другой комментарий — цитата в две строки; нажатие ведёт к оригиналу
|
if (mention && parent && parent !== focus) {
|
||||||
if (parent && parent !== focus) {
|
const to = document.createElement('button');
|
||||||
const quote = document.createElement('button');
|
to.type = 'button';
|
||||||
quote.type = 'button';
|
to.className = 'thread-comment__mention';
|
||||||
quote.className = 'thread-quote';
|
to.innerHTML = iconHtml('reply');
|
||||||
const qa = document.createElement('strong');
|
to.append(String(parent.authorLogin || ''));
|
||||||
qa.textContent = String(parent.authorLogin || '');
|
to.setAttribute('aria-label', `Ответ для ${parent.authorLogin || ''}. Перейти к его комментарию`);
|
||||||
const qt = document.createElement('span');
|
to.addEventListener('click', () => handlers.jumpTo(nodeKey(parent), key));
|
||||||
qt.textContent = parseMessageAttachments(resolveNodeText(parent)).text || 'Вложение';
|
main.append(to);
|
||||||
quote.append(qa, qt);
|
|
||||||
quote.setAttribute('aria-label', `Ответ на комментарий ${parent.authorLogin || ''}. Перейти к нему`);
|
|
||||||
quote.addEventListener('click', () => handlers.jumpTo(nodeKey(parent), key));
|
|
||||||
item.append(quote);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed.attachments.length) {
|
if (parsed.attachments.length) {
|
||||||
item.append(createAttachmentCarouselElement(parsed.attachments, {
|
main.append(createAttachmentCarouselElement(parsed.attachments, {
|
||||||
gateway: state.entrySettings.arweaveServer,
|
gateway: state.entrySettings.arweaveServer,
|
||||||
messageTimestampMs: node?.createdAtMs,
|
messageTimestampMs: node?.createdAtMs,
|
||||||
authorLogin: node?.authorLogin,
|
authorLogin: node?.authorLogin,
|
||||||
@@ -1128,15 +1153,10 @@ function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
|||||||
const text = document.createElement('p');
|
const text = document.createElement('p');
|
||||||
text.className = 'thread-comment__text';
|
text.className = 'thread-comment__text';
|
||||||
appendShineMessageLinks(text, parsed.text, { navigate: handlers?.navigate });
|
appendShineMessageLinks(text, parsed.text, { navigate: handlers?.navigate });
|
||||||
item.append(text);
|
main.append(text);
|
||||||
|
|
||||||
const actions = document.createElement('div');
|
const actions = document.createElement('div');
|
||||||
actions.className = 'thread-comment__actions';
|
actions.className = 'thread-comment__actions';
|
||||||
const reply = document.createElement('button');
|
|
||||||
reply.type = 'button';
|
|
||||||
reply.className = 'thread-comment__reply';
|
|
||||||
reply.textContent = 'Ответить';
|
|
||||||
reply.addEventListener('click', () => handlers.setReplyTo(node));
|
|
||||||
|
|
||||||
setMessageReactionState(target, node?.likedByMe === true ? 'liked' : 'unliked');
|
setMessageReactionState(target, node?.likedByMe === true ? 'liked' : 'unliked');
|
||||||
const liked = getMessageReactionState(target) === 'liked';
|
const liked = getMessageReactionState(target) === 'liked';
|
||||||
@@ -1154,6 +1174,14 @@ function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
|||||||
finally { if (like.isConnected) like.disabled = false; }
|
finally { if (like.isConnected) like.disabled = false; }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const replies = Number(node?.repliesCount || 0);
|
||||||
|
const reply = document.createElement('button');
|
||||||
|
reply.type = 'button';
|
||||||
|
reply.className = 'channel-action-item thread-comment__reply';
|
||||||
|
reply.innerHTML = `${iconHtml('message')}<span>${replies || ''}</span>`;
|
||||||
|
reply.setAttribute('aria-label', `Ответить ${author}`);
|
||||||
|
reply.addEventListener('click', () => handlers.setReplyTo(node));
|
||||||
|
|
||||||
const more = document.createElement('button');
|
const more = document.createElement('button');
|
||||||
more.type = 'button';
|
more.type = 'button';
|
||||||
more.className = 'channel-action-item thread-comment__more';
|
more.className = 'channel-action-item thread-comment__more';
|
||||||
@@ -1186,12 +1214,80 @@ function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
|||||||
}
|
}
|
||||||
const menu = createDropdownMenu({ anchorEl: more, items: menuItems });
|
const menu = createDropdownMenu({ anchorEl: more, items: menuItems });
|
||||||
item.cleanup = () => menu.destroy();
|
item.cleanup = () => menu.destroy();
|
||||||
|
head.append(more);
|
||||||
|
|
||||||
actions.append(reply, like, more);
|
actions.append(like, reply);
|
||||||
item.append(actions);
|
main.append(actions);
|
||||||
|
item.append(who, main);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Сколько ответов внутри ветки видно сразу; остальные – по «Ещё N ответов».
|
||||||
|
const THREAD_GROUP_VISIBLE_REPLIES = 2;
|
||||||
|
|
||||||
|
// Ветка ответа верхнего уровня: сам ответ и всё дерево под ним одной колонкой с линией, как в Threads.
|
||||||
|
// Ответы глубже, чем отдал сервер, открываются отдельным обсуждением этого ответа.
|
||||||
|
function renderReplyGroup(branch, { focus, channelOwner, handlers }) {
|
||||||
|
const group = document.createElement('div');
|
||||||
|
group.className = 'thread-group';
|
||||||
|
group.append(renderComment({ node: branch.node, parent: focus, focus, channelOwner, handlers }));
|
||||||
|
|
||||||
|
const nested = [];
|
||||||
|
const walk = (children, parent) => {
|
||||||
|
(Array.isArray(children) ? children : []).forEach((child) => {
|
||||||
|
if (!child?.node) return;
|
||||||
|
nested.push({ node: child.node, parent, loaded: Array.isArray(child.children) ? child.children.length : 0 });
|
||||||
|
walk(child.children, child.node);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
walk(branch.children, branch.node);
|
||||||
|
if (!nested.length) return group;
|
||||||
|
|
||||||
|
group.classList.add('has-replies');
|
||||||
|
const list = document.createElement('div');
|
||||||
|
list.className = 'thread-replies';
|
||||||
|
let previous = branch.node;
|
||||||
|
nested.forEach(({ node, parent, loaded }, index) => {
|
||||||
|
const comment = renderComment({ node, parent, focus, channelOwner, handlers, nested: true, mention: parent !== previous });
|
||||||
|
if (index >= THREAD_GROUP_VISIBLE_REPLIES) comment.classList.add('is-collapsed');
|
||||||
|
list.append(comment);
|
||||||
|
const unloaded = Number(node?.repliesCount || 0) - loaded;
|
||||||
|
if (unloaded > 0) {
|
||||||
|
const deeper = document.createElement('button');
|
||||||
|
deeper.type = 'button';
|
||||||
|
deeper.className = 'thread-more thread-more--deeper';
|
||||||
|
if (index >= THREAD_GROUP_VISIBLE_REPLIES) deeper.classList.add('is-collapsed');
|
||||||
|
deeper.textContent = `Ответы на этот комментарий · ${unloaded}`;
|
||||||
|
deeper.addEventListener('click', () => handlers.onOpenThread(buildTargetFromNode(node)));
|
||||||
|
list.append(deeper);
|
||||||
|
}
|
||||||
|
previous = node;
|
||||||
|
});
|
||||||
|
const hidden = nested.length - THREAD_GROUP_VISIBLE_REPLIES;
|
||||||
|
if (hidden > 0) {
|
||||||
|
const expand = document.createElement('button');
|
||||||
|
expand.type = 'button';
|
||||||
|
expand.className = 'thread-more';
|
||||||
|
expand.textContent = `Ещё ${hidden} ${pluralRu(hidden, 'ответ', 'ответа', 'ответов')}`;
|
||||||
|
expand.addEventListener('click', () => {
|
||||||
|
list.classList.add('is-expanded');
|
||||||
|
expand.remove();
|
||||||
|
});
|
||||||
|
list.append(expand);
|
||||||
|
}
|
||||||
|
group.append(list);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pluralRu(n, one, few, many) {
|
||||||
|
const mod10 = n % 10;
|
||||||
|
const mod100 = n % 100;
|
||||||
|
if (mod10 === 1 && mod100 !== 11) return one;
|
||||||
|
if (mod10 >= 2 && mod10 <= 4 && (mod100 < 12 || mod100 > 14)) return few;
|
||||||
|
return many;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderDescendants(items, handlers, nextNumber, depth = 0, parent = null) {
|
function renderDescendants(items, handlers, nextNumber, depth = 0, parent = null) {
|
||||||
const wrap = document.createElement('div');
|
const wrap = document.createElement('div');
|
||||||
wrap.className = 'stack';
|
wrap.className = 'stack';
|
||||||
@@ -1266,6 +1362,9 @@ function setThreadMuted(key, muted) {
|
|||||||
try { localStorage.setItem(THREAD_MUTE_KEY, JSON.stringify(all)); } catch { /* приватный режим */ }
|
try { localStorage.setItem(THREAD_MUTE_KEY, JSON.stringify(all)); } catch { /* приватный режим */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Глубина дерева ответов за один запрос; что глубже – открывается обсуждением конкретного ответа.
|
||||||
|
const THREAD_LOAD_DEPTH = 8;
|
||||||
|
|
||||||
// Черновик и адресат ответа принадлежат конкретному обсуждению
|
// Черновик и адресат ответа принадлежат конкретному обсуждению
|
||||||
const threadDrafts = new Map();
|
const threadDrafts = new Map();
|
||||||
|
|
||||||
@@ -1758,7 +1857,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
selector.message = { ...resolvedMessage };
|
selector.message = { ...resolvedMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = await authService.getMessageThread(resolvedMessage, 20, 2, 50, state.session.login);
|
const payload = await authService.getMessageThread(resolvedMessage, 20, THREAD_LOAD_DEPTH, 50, state.session.login);
|
||||||
if (disposed || seq !== refreshSeq) return;
|
if (disposed || seq !== refreshSeq) return;
|
||||||
skeleton?.remove();
|
skeleton?.remove();
|
||||||
|
|
||||||
@@ -1881,7 +1980,11 @@ export function render({ navigate, route, chrome }) {
|
|||||||
if (focus) {
|
if (focus) {
|
||||||
const focusWrap = document.createElement('div');
|
const focusWrap = document.createElement('div');
|
||||||
focusWrap.className = 'thread-block thread-block--focus';
|
focusWrap.className = 'thread-block thread-block--focus';
|
||||||
focusWrap.append(renderNodeCard(focus, '', handlers, focusOrdinal || Number(selector?.message?.blockNumber ?? 0), { focusPost: true, channelOwnerBlockchainName: selector?.channel?.ownerBlockchainName || '' }));
|
focusWrap.append(renderNodeCard(focus, '', handlers, focusOrdinal || Number(selector?.message?.blockNumber ?? 0), {
|
||||||
|
focusPost: true,
|
||||||
|
channelOwnerBlockchainName: selector?.channel?.ownerBlockchainName || '',
|
||||||
|
channel: { title, avatarAr, avatarSha256 },
|
||||||
|
}));
|
||||||
screen.append(focusWrap);
|
screen.append(focusWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1916,6 +2019,7 @@ export function render({ navigate, route, chrome }) {
|
|||||||
jumpTo: (key, fromKey) => {
|
jumpTo: (key, fromKey) => {
|
||||||
const el = listWrap.querySelector(`[data-message-key="${CSS.escape(key)}"]`);
|
const el = listWrap.querySelector(`[data-message-key="${CSS.escape(key)}"]`);
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
|
el.closest('.thread-replies')?.classList.add('is-expanded');
|
||||||
el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
el.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||||||
highlight(el);
|
highlight(el);
|
||||||
returnKey = fromKey;
|
returnKey = fromKey;
|
||||||
@@ -1931,8 +2035,9 @@ export function render({ navigate, route, chrome }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (comments.length) {
|
if (comments.length) {
|
||||||
comments.forEach(({ node, parent }) => {
|
descendants.forEach((branch) => {
|
||||||
try { listWrap.append(renderComment({ node, parent, focus, channelOwner, handlers: commentHandlers })); }
|
if (!branch?.node) return;
|
||||||
|
try { listWrap.append(renderReplyGroup(branch, { focus, channelOwner, handlers: commentHandlers })); }
|
||||||
catch (error) { logThreadRuntimeError('render_comment', error); }
|
catch (error) { logThreadRuntimeError('render_comment', error); }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
formatDayLabel,
|
formatDayLabel,
|
||||||
formatPostStamp,
|
formatPostStamp,
|
||||||
formatRelativeTime,
|
formatRelativeTime,
|
||||||
|
formatShortAge,
|
||||||
longPressFeel,
|
longPressFeel,
|
||||||
shareOrCopyLink,
|
shareOrCopyLink,
|
||||||
showToast,
|
showToast,
|
||||||
@@ -1871,6 +1872,7 @@ function renderPostCard(post, {
|
|||||||
onRepost,
|
onRepost,
|
||||||
onShare,
|
onShare,
|
||||||
onEdit,
|
onEdit,
|
||||||
|
channel = null,
|
||||||
isActive = () => true,
|
isActive = () => true,
|
||||||
}) {
|
}) {
|
||||||
const versionsTotal = Number(post?.versionsTotal || 1);
|
const versionsTotal = Number(post?.versionsTotal || 1);
|
||||||
@@ -1964,9 +1966,19 @@ function renderPostCard(post, {
|
|||||||
&& !isDiarySelector(selector)
|
&& !isDiarySelector(selector)
|
||||||
&& !!post.messageRef?.blockchainName
|
&& !!post.messageRef?.blockchainName
|
||||||
&& String(post.messageRef.blockchainName).trim().toLowerCase() === String(selector.ownerBlockchainName || '').trim().toLowerCase();
|
&& String(post.messageRef.blockchainName).trim().toLowerCase() === String(selector.ownerBlockchainName || '').trim().toLowerCase();
|
||||||
|
// Запись владельца – как пост в Threads: аватар и название канала слева сверху, текст и действия под названием.
|
||||||
|
const threadsLayout = isOwnerPost && Boolean(channel);
|
||||||
if (isOwnerPost) {
|
if (isOwnerPost) {
|
||||||
card.classList.add('channel-message-card--owner');
|
card.classList.add('channel-message-card--owner');
|
||||||
authorTile.hidden = true;
|
authorTile.hidden = !threadsLayout;
|
||||||
|
}
|
||||||
|
if (threadsLayout) {
|
||||||
|
card.classList.add('channel-message-card--threads');
|
||||||
|
const channelAvatar = createChannelAvatarElement(channel, 36);
|
||||||
|
channelAvatar.classList.add('channel-message-avatar');
|
||||||
|
avatar.replaceWith(channelAvatar);
|
||||||
|
loginEl.textContent = String(channel.displayTitle || channel.displayName || channel.name || post.authorLogin).trim();
|
||||||
|
if (post.timestampMs) timestamp.textContent = formatShortAge(post.timestampMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDeletedMessage = String(post.body || '').trim().toLowerCase() === 'удалено';
|
const isDeletedMessage = String(post.body || '').trim().toLowerCase() === 'удалено';
|
||||||
@@ -2137,8 +2149,10 @@ function renderPostCard(post, {
|
|||||||
await onShare(route);
|
await onShare(route);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Порядок как в макете V4: лайк → поделиться → обсуждение; дата и «⋯» — справа
|
// Порядок как в макете V4: лайк → поделиться → обсуждение; дата и «⋯» — справа.
|
||||||
actions.append(likeButton, shareButton, discussionButton);
|
// В раскладке Threads: лайк → обсуждение → поделиться, дата и «⋯» в шапке.
|
||||||
|
if (threadsLayout) actions.append(likeButton, discussionButton, shareButton);
|
||||||
|
else actions.append(likeButton, shareButton, discussionButton);
|
||||||
if (selector?.publicOrdinalUrlsAllowed && post.messageRef?.blockNumber != null) {
|
if (selector?.publicOrdinalUrlsAllowed && post.messageRef?.blockNumber != null) {
|
||||||
const streamRoute = makeShineChannelStreamRoute({
|
const streamRoute = makeShineChannelStreamRoute({
|
||||||
ownerBlockchainName: selector?.ownerBlockchainName,
|
ownerBlockchainName: selector?.ownerBlockchainName,
|
||||||
@@ -2226,7 +2240,7 @@ function renderPostCard(post, {
|
|||||||
}
|
}
|
||||||
if (versionsTotal > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions: post.versions }) });
|
if (versionsTotal > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions: post.versions }) });
|
||||||
attachMessageMenu(card, headRow, menuItems);
|
attachMessageMenu(card, headRow, menuItems);
|
||||||
if (isOwnerPost) {
|
if (isOwnerPost && !threadsLayout) {
|
||||||
if (post.timestampMs) timestamp.textContent = formatPostStamp(post.timestampMs);
|
if (post.timestampMs) timestamp.textContent = formatPostStamp(post.timestampMs);
|
||||||
const meta = document.createElement('div');
|
const meta = document.createElement('div');
|
||||||
meta.className = 'channel-message-meta';
|
meta.className = 'channel-message-meta';
|
||||||
@@ -2334,6 +2348,7 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
|
|||||||
onRepost: handlers.onRepost,
|
onRepost: handlers.onRepost,
|
||||||
onShare: handlers.onShare,
|
onShare: handlers.onShare,
|
||||||
onEdit: handlers.onEdit,
|
onEdit: handlers.onEdit,
|
||||||
|
channel: channelData.channel,
|
||||||
isActive: handlers.isActive,
|
isActive: handlers.isActive,
|
||||||
});
|
});
|
||||||
const key = messageRefKey(item.post.messageRef);
|
const key = messageRefKey(item.post.messageRef);
|
||||||
|
|||||||
@@ -93,6 +93,22 @@ export function formatListTime(timestampMs) {
|
|||||||
return new Intl.DateTimeFormat('ru-RU', { day: '2-digit', month: '2-digit', year: '2-digit' }).format(dt);
|
return new Intl.DateTimeFormat('ru-RU', { day: '2-digit', month: '2-digit', year: '2-digit' }).format(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Возраст записи в шапке поста и ответа: «сейчас», «5 мин», «2 ч», «3 д», потом «12 окт», в прошлом году «12 окт 2025».
|
||||||
|
export function formatShortAge(timestampMs) {
|
||||||
|
const ts = toNumber(timestampMs);
|
||||||
|
if (!ts) return '';
|
||||||
|
const ageMinutes = Math.max(0, Math.floor((Date.now() - ts) / 60000));
|
||||||
|
if (ageMinutes < 1) return 'сейчас';
|
||||||
|
if (ageMinutes < 60) return `${ageMinutes} мин`;
|
||||||
|
const ageHours = Math.floor(ageMinutes / 60);
|
||||||
|
if (ageHours < 24) return `${ageHours} ч`;
|
||||||
|
const ageDays = Math.floor(ageHours / 24);
|
||||||
|
if (ageDays < 7) return `${ageDays} д`;
|
||||||
|
const dt = new Date(ts);
|
||||||
|
const day = `${dt.getDate()} ${SHORT_MONTHS[dt.getMonth()]}`;
|
||||||
|
return dt.getFullYear() === new Date().getFullYear() ? day : `${day} ${dt.getFullYear()}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function formatRelativeTime(timestampMs) {
|
export function formatRelativeTime(timestampMs) {
|
||||||
const ts = toNumber(timestampMs);
|
const ts = toNumber(timestampMs);
|
||||||
if (!ts) return '–';
|
if (!ts) return '–';
|
||||||
|
|||||||
@@ -11,22 +11,39 @@
|
|||||||
.thread-context__open svg { width: 14px; height: 14px; }
|
.thread-context__open svg { width: 14px; height: 14px; }
|
||||||
|
|
||||||
.thread-section-title { margin: 12px 0 4px; font-size: .8125rem; font-weight: 600; color: var(--text-primary); }
|
.thread-section-title { margin: 12px 0 4px; font-size: .8125rem; font-weight: 600; color: var(--text-primary); }
|
||||||
.channels-screen .thread-comment { display: block; margin: 0 calc(-1 * var(--page-gutter)); padding: 7px var(--page-gutter) 5px; border: 0; border-radius: 0; background: transparent; scroll-margin: 16px; }
|
.thread-group { position: relative; padding: 12px 0 6px; }
|
||||||
.channels-screen .thread-comment + .thread-comment { border-top: 1px solid var(--divider-soft); }
|
.thread-group + .thread-group { border-top: 1px solid var(--border-subtle); }
|
||||||
.thread-comment.is-highlight { background: var(--surface-selected); box-shadow: inset 3px 0 var(--accent); }
|
.channels-screen .thread-comment { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 10px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; scroll-margin: 16px; }
|
||||||
.thread-comment__person { display: flex; align-items: center; gap: 7px; min-height: 26px; margin-bottom: 4px; font-size: .875rem; font-weight: 600; }
|
.channels-screen .thread-comment--nested { grid-template-columns: 28px minmax(0, 1fr); margin-top: 10px; }
|
||||||
.thread-comment__who { display: inline-flex; align-items: center; gap: 7px; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text-primary); font: inherit; cursor: pointer; }
|
.thread-comment.is-highlight { background: var(--surface-selected); box-shadow: 0 0 0 6px var(--surface-selected); border-radius: 4px; }
|
||||||
.thread-comment__who .avatar.thread-comment__avatar { width: 24px; height: 24px; min-width: 24px; min-height: 24px; font-size: 11px; }
|
.thread-comment__who { align-self: start; padding: 0; border: 0; background: transparent; cursor: pointer; }
|
||||||
.thread-comment__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
.thread-comment__who .avatar.thread-comment__avatar { width: 36px; height: 36px; min-width: 36px; min-height: 36px; font-size: 14px; }
|
||||||
.thread-comment__badge { padding: 1px 5px; border-radius: 5px; background: var(--surface-selected); color: var(--action); font-size: .625rem; font-weight: 400; white-space: nowrap; }
|
.thread-comment--nested .thread-comment__who .avatar.thread-comment__avatar { width: 28px; height: 28px; min-width: 28px; min-height: 28px; font-size: 12px; }
|
||||||
.thread-comment__person time { margin-left: auto; flex-shrink: 0; color: var(--text-secondary); font-size: .75rem; font-weight: 400; }
|
.thread-comment__main { min-width: 0; }
|
||||||
.thread-comment__text { margin: 0; font-size: .9375rem; line-height: 1.4375rem; white-space: pre-wrap; overflow-wrap: anywhere; }
|
.thread-comment__head { display: flex; align-items: center; gap: 6px; min-height: 22px; }
|
||||||
.thread-comment__actions { display: flex; align-items: center; gap: 12px; margin-top: 2px; color: var(--text-secondary); }
|
.thread-comment__name { min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: .9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
|
||||||
.thread-comment__actions > button { min-height: 32px; min-width: 32px; padding: 0 4px; display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: .75rem; cursor: pointer; }
|
.thread-comment__badge { padding: 1px 6px; border-radius: 6px; background: var(--surface-selected); color: var(--action); font-size: .6875rem; white-space: nowrap; }
|
||||||
.thread-comment__actions .thread-comment__reply { padding-left: 0; color: var(--action); }
|
.thread-comment__head time { flex-shrink: 0; color: var(--text-secondary); font-size: .875rem; }
|
||||||
.thread-comment__actions svg { width: 21px; height: 21px; }
|
.thread-comment__head .thread-comment__more { width: 36px; min-width: 36px; height: 28px; min-height: 28px; margin: -4px -8px -4px auto; padding: 0; border: 0; background: transparent; color: var(--text-secondary); }
|
||||||
.thread-comment__actions .thread-comment__more { margin-left: auto; }
|
.thread-comment__head .thread-comment__more svg { width: 20px; height: 20px; }
|
||||||
.thread-comment__actions .thread-comment__more svg { width: 24px; height: 24px; }
|
.thread-comment__mention { display: inline-flex; align-items: center; gap: 3px; margin: 1px 0 0; padding: 0; border: 0; background: transparent; color: var(--action); font: inherit; font-size: .8125rem; cursor: pointer; }
|
||||||
|
.thread-comment__mention svg { width: 14px; height: 14px; }
|
||||||
|
.thread-comment__text { margin: 2px 0 0; font-size: .9375rem; line-height: 1.4375rem; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||||
|
.thread-comment__actions { display: flex; align-items: center; gap: 4px; margin: 2px 0 0 -10px; color: var(--text-secondary); }
|
||||||
|
.thread-comment__actions > button { min-height: 36px; min-width: 40px; padding: 0 10px; display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-size: .8125rem; cursor: pointer; }
|
||||||
|
.thread-comment__actions svg { width: 19px; height: 19px; }
|
||||||
|
.thread-comment__actions span:empty { display: none; }
|
||||||
|
|
||||||
|
/* Ветка: ответы на ответы одной колонкой со сдвигом под аватар, от аватара родителя – линия с изгибом к каждому ответу. */
|
||||||
|
.thread-replies { position: relative; margin-left: 46px; }
|
||||||
|
.thread-replies > .thread-comment::before { content: ''; position: absolute; top: -10px; left: -29px; width: 22px; height: 24px; border-left: 2px solid var(--border-control); border-bottom: 2px solid var(--border-control); border-bottom-left-radius: 12px; pointer-events: none; }
|
||||||
|
.thread-replies > :not(:last-child)::after { content: ''; position: absolute; top: 0; bottom: -10px; left: -29px; border-left: 2px solid var(--border-control); pointer-events: none; }
|
||||||
|
.thread-group.has-replies > .thread-comment:first-child::after { content: ''; position: absolute; top: 40px; bottom: -12px; left: 17px; border-left: 2px solid var(--border-control); pointer-events: none; }
|
||||||
|
.thread-replies:not(.is-expanded) > .is-collapsed { display: none; }
|
||||||
|
.thread-more { position: relative; display: block; min-height: 36px; margin-top: 6px; padding: 0; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; }
|
||||||
|
.thread-replies > .thread-more::before { content: ''; position: absolute; top: -6px; left: -29px; width: 22px; height: 24px; border-left: 2px solid var(--border-control); border-bottom: 2px solid var(--border-control); border-bottom-left-radius: 12px; }
|
||||||
|
.thread-more:hover { color: var(--text-primary); }
|
||||||
|
.thread-more--deeper { color: var(--action); font-weight: 500; }
|
||||||
|
|
||||||
.thread-quote { display: block; width: 100%; margin: 0 0 7px; padding: 5px 9px; border: 0; border-left: 2px solid var(--quote-line); border-radius: 0 6px 6px 0; background: var(--quote-bg); color: var(--text-secondary); font: inherit; font-size: .75rem; line-height: 1.125rem; text-align: left; cursor: pointer; }
|
.thread-quote { display: block; width: 100%; margin: 0 0 7px; padding: 5px 9px; border: 0; border-left: 2px solid var(--quote-line); border-radius: 0 6px 6px 0; background: var(--quote-bg); color: var(--text-secondary); font: inherit; font-size: .75rem; line-height: 1.125rem; text-align: left; cursor: pointer; }
|
||||||
.thread-quote strong { display: block; color: var(--action); font-weight: 500; }
|
.thread-quote strong { display: block; color: var(--action); font-weight: 500; }
|
||||||
|
|||||||
@@ -111,3 +111,28 @@
|
|||||||
|
|
||||||
.channels-screen--channel, .channels-screen--thread { padding-bottom: 8px; }
|
.channels-screen--channel, .channels-screen--thread { padding-bottom: 8px; }
|
||||||
.channel-message-card--owner .message-attachment-media { height: auto; max-height: 70vh; object-fit: cover; }
|
.channel-message-card--owner .message-attachment-media { height: auto; max-height: 70vh; object-fit: cover; }
|
||||||
|
|
||||||
|
/* Запись канала в раскладке Threads: аватар канала слева, название и возраст сверху, текст и действия – колонкой под названием. */
|
||||||
|
.channels-screen .channel-message-card.channel-message-card--threads { padding: 14px 0 4px 48px; }
|
||||||
|
.channel-message-card--threads .channel-message-head-row { flex-wrap: nowrap; min-height: 22px; }
|
||||||
|
.channel-message-card--threads .channel-message-author-tile { gap: 0; min-height: 22px; }
|
||||||
|
.channel-message-card--threads .avatar.channel-message-avatar { position: absolute; top: 14px; left: 0; }
|
||||||
|
.channel-message-card--threads .avatar.channel-profile-avatar { width: 36px; height: 36px; min-width: 36px; min-height: 36px; border-radius: 10px; font-size: 15px; }
|
||||||
|
.channel-message-card--threads .author-line-login { font-size: .9375rem; }
|
||||||
|
.channel-message-card--threads .channel-message-author .channel-message-time::before { content: none; }
|
||||||
|
.channel-message-card--threads .channel-message-time { font-size: .875rem; line-height: 1.25rem; }
|
||||||
|
.channel-message-card--threads .channel-message-more { width: 36px; height: 28px; margin: -4px -8px -4px auto; display: inline-grid; place-items: center; }
|
||||||
|
.channels-screen .channel-message-card--threads .channel-message-body { margin-top: 2px; font-size: .9375rem; line-height: 1.4375rem; }
|
||||||
|
.channel-message-card--threads .message-attachment-carousel { width: 100%; margin: 8px 0 2px; }
|
||||||
|
.channel-message-card--threads .message-attachment-carousel-viewport { border: 1px solid var(--border-subtle); border-radius: 12px; }
|
||||||
|
.channel-message-card--threads .channel-message-actions { min-height: 40px; margin: 2px 0 0 -10px; }
|
||||||
|
.channel-message-card--threads .channel-action-item { width: auto; min-width: 44px; min-height: 40px; padding: 0 12px 0 10px; gap: 5px; }
|
||||||
|
.channel-message-card--threads .channel-action-icon svg, .channel-message-card--threads .channel-action-share .channel-action-icon svg { width: 21px; height: 21px; }
|
||||||
|
.channel-message-card--threads .channel-action-counter { font-size: .8125rem; }
|
||||||
|
/* Открытая запись в обсуждении: аватар в шапке, текст на всю ширину и крупнее. */
|
||||||
|
.channels-screen .channel-message-card.channel-message-card--threads-focus { padding: 14px 0 4px; }
|
||||||
|
.channel-message-card--threads-focus .channel-message-head-row { min-height: 40px; }
|
||||||
|
.channel-message-card--threads-focus .channel-message-author-tile { gap: 10px; }
|
||||||
|
.channel-message-card--threads-focus .avatar.channel-message-avatar { position: relative; top: auto; }
|
||||||
|
.channels-screen .channel-message-card--threads-focus .channel-message-body { margin-top: 10px; font-size: 1.0625rem; line-height: 1.55; }
|
||||||
|
.channel-message-card--threads-focus .channel-message-actions { margin-top: 6px; }
|
||||||
|
|||||||
Reference in New Issue
Block a user