UI: карточка автора в канале, профиль user и назад по истории

This commit is contained in:
AidarKC
2026-05-19 13:58:49 +03:00
parent db2d9a666b
commit 90d10086d7
10 changed files with 80 additions and 28 deletions
+20 -5
View File
@@ -17,6 +17,7 @@ import {
softHaptic,
} from '../services/channels-ux.js';
import { openSpeechInputModal } from '../components/speech-input-modal.js';
import { navigateBack } from '../router.js';
export const pageMeta = { id: 'channel-view', title: 'Канал' };
const CHANNEL_TYPE_PERSONAL = 100;
@@ -628,8 +629,9 @@ function renderPostCard(post, {
const card = document.createElement('article');
card.className = 'card stack channel-message-card';
const topRow = document.createElement('div');
topRow.className = 'channel-message-top';
const authorTile = document.createElement('button');
authorTile.type = 'button';
authorTile.className = 'channel-message-author-tile';
const avatar = document.createElement('div');
avatar.className = 'channel-message-avatar';
@@ -654,13 +656,19 @@ function renderPostCard(post, {
title.append(loginEl, numberEl);
authorBlock.append(title, timestamp);
topRow.append(avatar, authorBlock);
authorTile.append(avatar, authorBlock);
authorTile.addEventListener('click', (event) => {
event.stopPropagation();
const cleanLogin = String(post.authorLogin || '').trim();
if (!cleanLogin) return;
navigate(`user/${encodeRoutePart(cleanLogin)}/channel-view`);
});
const body = document.createElement('p');
body.className = 'channel-message-body';
body.textContent = post.body;
card.append(topRow, body);
card.append(authorTile, body);
const refKey = messageRefKey(post.messageRef);
if (refKey) {
@@ -688,6 +696,7 @@ function renderPostCard(post, {
`;
likeButton.disabled = isPending;
likeButton.addEventListener('click', async (event) => {
event.stopPropagation();
animatePress(event.currentTarget);
if (isPending) return;
if (!isLiked) {
@@ -710,6 +719,7 @@ function renderPostCard(post, {
<span class="channel-action-counter">${post.repliesCount || 0}</span>
`;
replyButton.addEventListener('click', (event) => {
event.stopPropagation();
animatePress(event.currentTarget);
openReplyModal({
navigate,
@@ -726,6 +736,7 @@ function renderPostCard(post, {
<span class="channel-action-label">Тред</span>
`;
openThreadButton.addEventListener('click', (event) => {
event.stopPropagation();
animatePress(event.currentTarget);
const route = buildThreadRoute(post.messageRef, selector);
if (route) navigate(route);
@@ -747,6 +758,10 @@ function renderPostCard(post, {
actions.append(openThreadButton, shareButton);
card.append(actions);
card.addEventListener('click', () => {
const route = buildThreadRoute(post.messageRef, selector);
if (route) navigate(route);
});
return card;
}
@@ -978,7 +993,7 @@ export function render({ navigate, route }) {
screen.append(
renderHeader({
title: '',
leftAction: { label: '<', onClick: () => navigate('channels-list') },
leftAction: { label: '<', onClick: () => navigateBack() },
}),
);
screen.append(statusBox);