SHA256
Доработать UI до MVP
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { mountPublicChannelSidebar } from '../services/public-channel-sidebar.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { iconHtml } from '../components/ui-icon.js';
|
||||
import { rememberChannelPosition, readChannelPosition, restoreChannelPosition } from '../services/channel-view-state.js';
|
||||
@@ -41,6 +42,7 @@ import {
|
||||
extractLoginFromBlockchainName,
|
||||
makeProfileRoute,
|
||||
makeShineMessageRoute,
|
||||
makeShineChannelStreamRoute,
|
||||
makeShineChannelAboutRoute,
|
||||
makeShineChannelDonateRoute,
|
||||
} from '../services/shine-routes.js';
|
||||
@@ -243,6 +245,8 @@ function buildThreadRoute(messageRef, selector) {
|
||||
ownerLogin,
|
||||
messageBlockchainName: messageRef.blockchainName,
|
||||
messageBlockNumber: messageRef.blockNumber,
|
||||
channelName: selector.channelName,
|
||||
channelOwnerBlockchainName: selector.ownerBlockchainName,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2136,6 +2140,14 @@ function renderPostCard(post, {
|
||||
|
||||
// Порядок как в макете V4: лайк → поделиться → обсуждение; дата и «⋯» — справа
|
||||
actions.append(likeButton, shareButton, discussionButton);
|
||||
if (post.messageRef?.blockNumber != null) {
|
||||
const streamRoute = makeShineChannelStreamRoute({
|
||||
ownerBlockchainName: selector?.ownerBlockchainName,
|
||||
channelName: selector?.channelName || '',
|
||||
messageBlockNumber: post.messageRef.blockNumber,
|
||||
});
|
||||
if (streamRoute) menuItems.unshift({ label: 'Ссылка на сообщение в ленте', iconHtml: iconHtml('share'), action: () => onShare(streamRoute) });
|
||||
}
|
||||
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
if (post.msgSubType === MSG_SUBTYPE_TEXT_REPOST && post.targetRef?.blockchainName && Number.isFinite(post.targetRef?.blockNumber) && post.targetRef?.blockHash) {
|
||||
const originalBtn = document.createElement('button');
|
||||
@@ -2368,6 +2380,14 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
|
||||
screen.append(feed);
|
||||
}
|
||||
|
||||
const requestedBlock = String(handlers.scrollToMessageBlockNumber || '').trim();
|
||||
if (/^[0-9]+$/.test(requestedBlock)) {
|
||||
const card = [...screen.querySelectorAll('.channel-message-card[data-message-key]')].find((el) => {
|
||||
const parts = String(el.dataset.messageKey || '').split(':');
|
||||
return parts.length >= 3 && parts[parts.length - 2] === requestedBlock;
|
||||
});
|
||||
if (card) pendingScrollByRoute.set(routeKey, card.dataset.messageKey);
|
||||
}
|
||||
const hasPendingScrollTarget = pendingScrollByRoute.has(routeKey);
|
||||
const restorePosition = handlers.restorePosition;
|
||||
const pendingScrollTimer = Number.isFinite(restorePosition) && !hasPendingScrollTarget ? 0 : applyPendingScroll(screen, routeKey, channelData.isOwnChannel || channelData.isDiary || unreadCount === 0);
|
||||
@@ -2442,12 +2462,14 @@ function renderSkeleton(screen) {
|
||||
|
||||
export function render({ navigate, route, chrome }) {
|
||||
const channelId = route.params.channelId || '';
|
||||
const scrollToMessageBlockNumber = route.params.scrollToMessageBlockNumber || '';
|
||||
const routeSelector = buildSelectorFromRoute(route, channelId);
|
||||
const routeKey = `${routeSelector?.ownerBlockchainName || ''}:${routeSelector?.channelRootBlockNumber || ''}:${routeSelector?.channelRootBlockHash || ''}`;
|
||||
|
||||
const screen = document.createElement('section');
|
||||
screen.className = 'stack channels-screen channels-screen--channel';
|
||||
const positionKey = `${state.session.login}:channel:${routeKey}`;
|
||||
// A deep link must take precedence over a saved scroll position.
|
||||
|
||||
let disposed = false;
|
||||
let refreshSeq = 0;
|
||||
@@ -2963,6 +2985,7 @@ export function render({ navigate, route, chrome }) {
|
||||
};
|
||||
}
|
||||
activeChannelData = apiData;
|
||||
|
||||
if (channelMoreButton) {
|
||||
channelMoreButton.disabled = false;
|
||||
}
|
||||
@@ -2982,6 +3005,7 @@ export function render({ navigate, route, chrome }) {
|
||||
cleanupSeenTracking = renderBody(screen, navigate, routeKey, apiData, {
|
||||
chrome,
|
||||
restorePosition,
|
||||
scrollToMessageBlockNumber,
|
||||
showStatus,
|
||||
isActive: () => !disposed,
|
||||
onAddMessage: activeAddMessage = async () => {
|
||||
@@ -3072,6 +3096,10 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
onSubscribeChannel: (event) => subscribeToChannel(apiData, event),
|
||||
});
|
||||
if (!state.session.isAuthorized && !apiData?.isDiary) mountPublicChannelSidebar(screen, {
|
||||
owner: apiData?.channel?.ownerName || extractLoginFromBlockchainName(apiData?.selector?.ownerBlockchainName),
|
||||
channel: titleLabel, subscribers: apiData?.channel?.subscribersCount, navigate,
|
||||
});
|
||||
} catch (error) {
|
||||
if (disposed || seq !== refreshSeq) return;
|
||||
skeleton?.remove();
|
||||
|
||||
Reference in New Issue
Block a user