Добавить Canvas v4 для исследования связей

This commit is contained in:
AidarKC
2026-11-19 21:13:24 +03:00
parent 8f3b81c368
commit 859dbee1f1
19 changed files with 993 additions and 41 deletions
+33 -11
View File
@@ -38,7 +38,7 @@ import {
escapeHtml,
parseMessageAttachments,
} from '../services/attachment-format.js';
import { loadProfileSnapshot } from '../services/user-profile-params.js';
import { loadProfileSnapshot, profileDisplayName } from '../services/user-profile-params.js';
import { extractLoginFromBlockchainName, formatChannelAddress, makeProfileRoute, makeShineChannelRoute, makeShineMessageRoute } from '../services/shine-routes.js';
import { parsePublicationOrdinal, publicationAtOrdinal, ordinalForPublication } from '../services/channel-message-ordinals.js';
import { dropPageData, pageDataAge, readPageData, writePageData } from '../services/page-data-cache.js';
@@ -736,6 +736,17 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
if (node?.createdAtMs) timestamp.title = formatDateTime(new Date(node.createdAtMs));
authorBlock.append(title, timestamp);
authorTile.append(avatar, authorBlock);
const profileMenu = createDropdownMenu({
anchorEl: authorTile,
minWidth: 190,
dimBackground: false,
items: [{ label: t('screens.chat_view.text_004'), iconHtml: iconHtml('profile'), action: () => handlers.navigate(makeProfileRoute(author)) }],
});
authorTile.addEventListener('click', (event) => { event.stopPropagation(); profileMenu.toggle(); });
void loadThreadAvatarSnapshot(author).then((snapshot) => {
if (!loginEl.isConnected || (threadsLayout && isOwnerPost)) return;
loginEl.textContent = profileDisplayName(snapshot, author);
});
// Запись канала в обсуждении – как открытый пост в Threads: аватар и название канала в шапке, текст на всю ширину.
const threadsLayout = focusPost && (!isOwnerPost || Boolean(channel));
if (isOwnerPost) authorTile.hidden = !threadsLayout;
@@ -1057,12 +1068,8 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
if (!headRow.querySelector('.channel-message-type-button')) headRow.hidden = true;
}
card.append(actions);
authorTile.addEventListener('click', (event) => {
event.stopPropagation();
const login = String(node?.authorLogin || '').trim();
if (!login) return;
handlers.navigate(makeProfileRoute(login));
});
const priorCleanup = card.cleanup;
card.cleanup = () => { priorCleanup?.(); profileMenu.destroy(); };
return card;
}
@@ -1136,8 +1143,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
who.type = 'button';
who.className = 'thread-comment__who';
who.setAttribute('aria-label', t('screens.channel_thread_view.text_105', { value1: author }));
who.append(identity?.avatar || renderUserAvatar({ login: author, size: nested ? 'xs' : 'sm', className: 'thread-comment__avatar avatar-plain' }));
who.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
who.append(identity?.avatar || createThreadAvatar(author));
const main = document.createElement('div');
main.className = 'thread-comment__main';
@@ -1148,8 +1154,11 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
name.type = 'button';
name.className = 'thread-comment__name';
name.textContent = identity?.title || author;
name.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
head.append(name);
const login = document.createElement('span');
login.className = 'thread-comment__login';
login.textContent = `@${author.replace(/^@/, '')}`;
head.append(login);
if (!identity && channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
const badge = document.createElement('span');
badge.className = 'thread-comment__badge';
@@ -1162,6 +1171,19 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
head.append(time);
main.append(head);
const profileMenu = createDropdownMenu({
anchorEl: who,
minWidth: 190,
dimBackground: false,
items: [{ label: t('screens.chat_view.text_004'), iconHtml: iconHtml('profile'), action: () => handlers.navigate(makeProfileRoute(author)) }],
});
who.addEventListener('click', (event) => { event.stopPropagation(); profileMenu.toggle(); });
name.addEventListener('click', (event) => { event.stopPropagation(); profileMenu.toggle(); });
void loadThreadAvatarSnapshot(author).then((snapshot) => {
if (!name.isConnected || identity) return;
name.textContent = profileDisplayName(snapshot, author);
});
if (mention && parent && parent !== focus) {
const to = document.createElement('button');
to.type = 'button';
@@ -1252,7 +1274,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
} });
}
const menu = createDropdownMenu({ anchorEl: more, items: menuItems });
item.cleanup = () => menu.destroy();
item.cleanup = () => { profileMenu.destroy(); menu.destroy(); };
head.append(more);
const share = document.createElement('button');