SHA256
UI: одинаковые действия у записей и ответов, цепочка над ответом, вложения с текущего сервера
У ответов в ряду действий – лайк, ответы, поделиться (как у записи канала); «Поделиться» ведёт на обсуждение самого ответа. У записей в меню появилось «Скопировать текст», как у ответов. Открытый ответ – в раскладке Threads; над ним цепочка до исходной записи теми же карточками с линией (вместо серых блоков в две строки). Вложения с сервера доступа сначала ищутся на сервере, к которому подключены сейчас, затем на сервере сборки по умолчанию и только потом через PDA автора: раньше при подключении не к серверу по умолчанию картинки в ответах не находились.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
client.version=1.18.2
|
||||
client.version=1.18.3
|
||||
server.version=1.14.0
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
}());
|
||||
</script>
|
||||
<script>
|
||||
window.__SHINE_BUILD_HASH__ = '20261011213000';
|
||||
window.__SHINE_BUILD_HASH__ = '20261011224500';
|
||||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||||
</script>
|
||||
<script>
|
||||
|
||||
@@ -737,10 +737,13 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
authorBlock.append(title, timestamp);
|
||||
authorTile.append(avatar, authorBlock);
|
||||
// Запись канала в обсуждении – как открытый пост в Threads: аватар и название канала в шапке, текст на всю ширину.
|
||||
const threadsLayout = isOwnerPost && Boolean(channel);
|
||||
const threadsLayout = focusPost && (!isOwnerPost || Boolean(channel));
|
||||
if (isOwnerPost) authorTile.hidden = !threadsLayout;
|
||||
if (threadsLayout) {
|
||||
card.classList.add('channel-message-card--threads', 'channel-message-card--threads-focus');
|
||||
if (node?.createdAtMs) timestamp.textContent = formatShortAge(node.createdAtMs);
|
||||
}
|
||||
if (threadsLayout && isOwnerPost) {
|
||||
const title = String(channel.title || author).trim();
|
||||
const channelAvatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
@@ -932,6 +935,11 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
if (threadsLayout) actions.append(likeButton, discussionButton, shareButton);
|
||||
else actions.append(likeButton, shareButton, discussionButton);
|
||||
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
// Те же действия, что у ответов в обсуждении.
|
||||
menuItems.splice(1, 0, { label: 'Скопировать текст', iconHtml: iconHtml('copy'), action: async () => {
|
||||
try { await copyTextToClipboard(parsedText.text); showToast('Текст скопирован'); }
|
||||
catch { showToast('Не удалось скопировать', { kind: 'error' }); }
|
||||
} });
|
||||
if (repostTarget) {
|
||||
const originalButton = document.createElement('button');
|
||||
originalButton.type = 'button';
|
||||
@@ -1044,51 +1052,9 @@ function nodeKey(node) {
|
||||
return messageRefKey(buildTargetFromNode(node));
|
||||
}
|
||||
|
||||
// Исходная запись сверху: две строки, «Развернуть» — только если текст правда обрезан
|
||||
function renderThreadContext(node, { onOpenPost, onNavigate }) {
|
||||
const parsed = parseMessageAttachments(resolveNodeText(node));
|
||||
const box = document.createElement('section');
|
||||
box.className = 'thread-context';
|
||||
const text = document.createElement('p');
|
||||
text.className = 'thread-context__text';
|
||||
appendShineMessageLinks(text, parsed.text || (parsed.attachments.length ? 'Запись с вложением' : ''), { navigate: onNavigate });
|
||||
const meta = document.createElement('div');
|
||||
meta.className = 'thread-context__meta';
|
||||
const time = document.createElement('span');
|
||||
time.textContent = formatPostStamp(node?.createdAtMs);
|
||||
const expand = document.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'text-btn thread-context__expand';
|
||||
expand.textContent = 'Развернуть';
|
||||
expand.hidden = true;
|
||||
expand.addEventListener('click', () => {
|
||||
const open = box.classList.toggle('is-expanded');
|
||||
expand.textContent = open ? 'Свернуть' : 'Развернуть';
|
||||
});
|
||||
const toPost = document.createElement('button');
|
||||
toPost.type = 'button';
|
||||
toPost.className = 'text-btn thread-context__open';
|
||||
toPost.innerHTML = `<span>${parsed.attachments.length ? 'Запись с фото' : 'К записи'}</span>${iconHtml('open')}`;
|
||||
toPost.addEventListener('click', onOpenPost);
|
||||
meta.append(time, expand, toPost);
|
||||
box.append(text, meta);
|
||||
if (parsed.attachments.length) {
|
||||
box.append(createAttachmentCarouselElement(parsed.attachments, {
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
messageTimestampMs: node?.createdAtMs,
|
||||
authorLogin: node?.authorLogin,
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
fallbackServerLogin: state.entrySettings.shineServerLogin,
|
||||
}));
|
||||
}
|
||||
// обрезан ли текст — видно только после вставки в документ
|
||||
requestAnimationFrame(() => { expand.hidden = text.scrollHeight <= text.clientHeight + 1; });
|
||||
return box;
|
||||
}
|
||||
|
||||
// Ответ в обсуждении в раскладке Threads: аватар слева, имя и время сверху, «⋯» справа, под текстом – лайк и ответ.
|
||||
// nested – ответ внутри ветки (меньший аватар, линия от родителя); mention – показать, кому ответ, если это не предыдущий в ветке.
|
||||
function renderComment({ node, parent, focus, channelOwner, handlers, nested = false, mention = false }) {
|
||||
function renderComment({ node, parent, focus, channelOwner, handlers, nested = false, mention = false, identity = null }) {
|
||||
const target = buildTargetFromNode(node);
|
||||
const key = messageRefKey(target);
|
||||
const author = String(node?.authorLogin || 'автор');
|
||||
@@ -1104,7 +1070,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
who.type = 'button';
|
||||
who.className = 'thread-comment__who';
|
||||
who.setAttribute('aria-label', `Профиль ${author}`);
|
||||
who.append(renderUserAvatar({ login: author, size: nested ? 'xs' : 'sm', className: 'thread-comment__avatar' }));
|
||||
who.append(identity?.avatar || renderUserAvatar({ login: author, size: nested ? 'xs' : 'sm', className: 'thread-comment__avatar' }));
|
||||
who.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
||||
|
||||
const main = document.createElement('div');
|
||||
@@ -1115,10 +1081,10 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
const name = document.createElement('button');
|
||||
name.type = 'button';
|
||||
name.className = 'thread-comment__name';
|
||||
name.textContent = author;
|
||||
name.textContent = identity?.title || author;
|
||||
name.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
||||
head.append(name);
|
||||
if (channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
|
||||
if (!identity && channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'thread-comment__badge';
|
||||
badge.textContent = 'Автор';
|
||||
@@ -1216,7 +1182,15 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
item.cleanup = () => menu.destroy();
|
||||
head.append(more);
|
||||
|
||||
actions.append(like, reply);
|
||||
const share = document.createElement('button');
|
||||
share.type = 'button';
|
||||
share.className = 'channel-action-item thread-comment__share';
|
||||
share.innerHTML = iconHtml('share');
|
||||
share.setAttribute('aria-label', 'Поделиться комментарием');
|
||||
share.addEventListener('click', () => handlers.shareComment(node));
|
||||
|
||||
// Ряд действий как у записи канала: лайк, ответы, поделиться.
|
||||
actions.append(like, reply, share);
|
||||
main.append(actions);
|
||||
item.append(who, main);
|
||||
// Как в Threads: нажатие на ответ открывает его обсуждение (кнопки, ссылки и вложения работают сами по себе).
|
||||
@@ -1873,10 +1847,44 @@ export function render({ navigate, route, chrome }) {
|
||||
];
|
||||
};
|
||||
|
||||
const ancestorHandlers = {
|
||||
...handlers,
|
||||
jumpTo: () => {},
|
||||
setReplyTo: (node) => handlers.openReplyEditor(node),
|
||||
shareComment: (node) => openShareSheet({
|
||||
title: 'Поделиться',
|
||||
kicker: `${node.authorLogin} · запись`,
|
||||
text: parseMessageAttachments(resolveNodeText(node)).text,
|
||||
url: buildAbsoluteRouteUrl(buildThreadRouteFromTarget(buildTargetFromNode(node), selector, null)),
|
||||
}),
|
||||
};
|
||||
// Над открытым ответом – цепочка до исходной записи, как в Threads: те же карточки, соединённые линией.
|
||||
if (ancestors.length) {
|
||||
const ancestorsWrap = document.createElement('div');
|
||||
ancestorsWrap.className = 'thread-block thread-block--ancestors';
|
||||
ancestors.forEach((node) => ancestorsWrap.append(renderThreadContext(node, { onOpenPost: openPost, onNavigate: navigate })));
|
||||
const ownerBch = String(selector?.channel?.ownerBlockchainName || '').toLowerCase();
|
||||
ancestors.forEach((node, index) => {
|
||||
const isChannelPost = index === 0 && ownerBch && String(node?.authorBlockchainName || '').toLowerCase() === ownerBch;
|
||||
let identity = null;
|
||||
if (isChannelPost) {
|
||||
const avatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
avatar: (avatarAr || avatarSha256) ? { ar: avatarAr, sha256Hex: avatarSha256 } : null,
|
||||
authorLogin: node?.authorLogin,
|
||||
size: 'xl',
|
||||
className: 'channel-profile-avatar thread-comment__avatar',
|
||||
title,
|
||||
alt: 'Аватар канала',
|
||||
});
|
||||
avatar.style.setProperty('--channel-avatar-size', '36px');
|
||||
identity = { title, avatar };
|
||||
}
|
||||
try {
|
||||
const row = renderComment({ node, parent: null, focus: null, channelOwner, handlers: ancestorHandlers, identity });
|
||||
row.classList.add('thread-comment--ancestor');
|
||||
ancestorsWrap.append(row);
|
||||
} catch (error) { logThreadRuntimeError('render_ancestor', error); }
|
||||
});
|
||||
screen.append(ancestorsWrap);
|
||||
}
|
||||
if (focus) {
|
||||
@@ -1931,7 +1939,8 @@ export function render({ navigate, route, chrome }) {
|
||||
title: 'Поделиться комментарием',
|
||||
kicker: `${node.authorLogin} · комментарий`,
|
||||
text: parseMessageAttachments(resolveNodeText(node)).text,
|
||||
url: `${buildAbsoluteRouteUrl(buildThreadRouteFromTarget(focusTarget, selector, focusOrdinal))}#comment-${node?.messageRef?.blockNumber ?? ''}`,
|
||||
// Ссылка ведёт на обсуждение самого комментария – так же он открывается нажатием.
|
||||
url: buildAbsoluteRouteUrl(buildThreadRouteFromTarget(buildTargetFromNode(node), selector, null)),
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
@@ -2176,6 +2176,11 @@ function renderPostCard(post, {
|
||||
if (streamRoute) menuItems.unshift({ label: 'Ссылка на сообщение в ленте', iconHtml: iconHtml('share'), action: () => onShare(streamRoute) });
|
||||
}
|
||||
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
// Те же действия, что у ответов в обсуждении.
|
||||
menuItems.splice(1, 0, { label: 'Скопировать текст', iconHtml: iconHtml('copy'), action: async () => {
|
||||
try { await copyTextToClipboard(parsedBody.text); showToast('Текст скопирован'); }
|
||||
catch { showToast('Не удалось скопировать', { kind: 'error' }); }
|
||||
} });
|
||||
if (post.msgSubType === MSG_SUBTYPE_TEXT_REPOST && post.targetRef?.blockchainName && Number.isFinite(post.targetRef?.blockNumber) && post.targetRef?.blockHash) {
|
||||
const originalBtn = document.createElement('button');
|
||||
originalBtn.type = 'button';
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
DEFAULT_SHINE_SERVER_HTTP,
|
||||
resolveShineServerForUserLogin,
|
||||
} from './shine-server-resolver.js';
|
||||
import { state } from '../state.js';
|
||||
|
||||
const ACCESS_SERVER_CACHE_TTL_MS = 60_000;
|
||||
const accessServerCache = new Map();
|
||||
@@ -158,9 +159,14 @@ export async function resolvePublicFileUrl({
|
||||
solanaEndpoint,
|
||||
fallbackServerLogin = '',
|
||||
} = {}) {
|
||||
const currentServerUrl = publicFileUrl(DEFAULT_SHINE_SERVER_HTTP, sha256);
|
||||
if (await publicFileExists(currentServerUrl)) {
|
||||
return currentServerUrl;
|
||||
// Сначала – сервер, к которому подключены сейчас (у большинства читателей он же сервер автора),
|
||||
// затем сервер сборки по умолчанию; только потом ищем сервер автора через его PDA.
|
||||
const nearbyBases = [...new Set([state.entrySettings?.shineServerHttp, DEFAULT_SHINE_SERVER_HTTP]
|
||||
.map((base) => String(base || '').trim().replace(/\/$/, ''))
|
||||
.filter(Boolean))];
|
||||
for (const base of nearbyBases) {
|
||||
const url = publicFileUrl(base, sha256);
|
||||
if (await publicFileExists(url)) return url;
|
||||
}
|
||||
|
||||
const cleanLogin = String(authorLogin || '').trim().toLowerCase();
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
/* Обсуждение (макет V4): контекст записи, «Комментарии · N», плоский список, строка ввода. */
|
||||
.channels-screen--thread { gap: 0; }
|
||||
.thread-block { display: grid; gap: 0; min-width: 0; }
|
||||
.thread-context { padding: 10px 0 8px; border-bottom: 1px solid var(--border-subtle); font-size: .875rem; line-height: 1.25rem; }
|
||||
.thread-block--ancestors .thread-context { opacity: .8; }
|
||||
.thread-context__text { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.thread-context.is-expanded .thread-context__text { display: block; }
|
||||
.thread-context__meta { display: flex; align-items: center; gap: 12px; min-height: 32px; color: var(--text-secondary); font-size: .75rem; }
|
||||
.thread-context__expand, .thread-context__open { min-height: 32px; padding: 0 4px; border: 0; background: transparent; color: var(--action); font: inherit; font-size: .75rem; cursor: pointer; }
|
||||
.thread-context__open { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
|
||||
.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-group { position: relative; padding: 12px 0 6px; }
|
||||
@@ -45,6 +37,13 @@
|
||||
.thread-more:hover { color: var(--text-primary); }
|
||||
.thread-more--deeper { color: var(--action); font-weight: 500; }
|
||||
|
||||
/* Цепочка над открытым ответом: звенья соединены линией от аватара к следующему. */
|
||||
.thread-block--ancestors { padding-top: 12px; }
|
||||
.channels-screen .thread-comment--ancestor { padding-bottom: 14px; }
|
||||
.thread-comment--ancestor::after { content: ''; position: absolute; top: 42px; bottom: 0; left: 17px; border-left: 2px solid var(--border-control); pointer-events: none; }
|
||||
.thread-comment--ancestor .avatar.channel-profile-avatar { width: 36px; height: 36px; min-width: 36px; min-height: 36px; border-radius: 10px; font-size: 15px; }
|
||||
.thread-block--ancestors + .thread-block--focus .channel-message-card--threads-focus { padding-top: 0; }
|
||||
|
||||
.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 span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
|
||||
Reference in New Issue
Block a user