SHA256
Доработать UI до MVP
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
client.version=1.15.1
|
||||
client.version=1.15.2
|
||||
server.version=1.13.0
|
||||
|
||||
@@ -1395,6 +1395,14 @@ async function redirectToActiveKeyRotationIfNeeded() {
|
||||
function renderApp() {
|
||||
syncTrackedRouteHistory(window.location.pathname || '/');
|
||||
const route = getRoute();
|
||||
if (state.session.isAuthorized) {
|
||||
const returnPath = window.sessionStorage.getItem('shine-public-return-path');
|
||||
if (returnPath && returnPath.startsWith('/SHiNE/')) {
|
||||
window.sessionStorage.removeItem('shine-public-return-path');
|
||||
navigate(returnPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const pageId = route.pageId || (state.session.isAuthorized ? 'messages-list' : 'start-view');
|
||||
|
||||
if (!state.session.isAuthorized && !PRE_AUTH_PAGES.includes(pageId) && !GUEST_ALLOWED_PAGES.has(pageId)) {
|
||||
|
||||
@@ -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';
|
||||
@@ -1617,7 +1618,7 @@ export function render({ navigate, route, chrome }) {
|
||||
try {
|
||||
let resolvedMessage = selector.message;
|
||||
if (selector.short?.ownerBlockchainName && selector.short?.channelName) {
|
||||
const ownFeed = await authService.listSubscriptionsFeed(state.session.login, 1000);
|
||||
const ownFeed = state.session.isAuthorized ? await authService.listSubscriptionsFeed(state.session.login, 1000) : {};
|
||||
if (disposed || seq !== refreshSeq) return;
|
||||
const allRows = [
|
||||
...(Array.isArray(ownFeed?.ownedChannels) ? ownFeed.ownedChannels : []),
|
||||
@@ -1666,6 +1667,17 @@ export function render({ navigate, route, chrome }) {
|
||||
// ignore owner feed lookup errors
|
||||
}
|
||||
}
|
||||
if (!channel && ownerLoginFromBch) {
|
||||
try {
|
||||
const publicChannels = await authService.listUserProfileChannels(ownerLoginFromBch, 'owned', 500, 0, true);
|
||||
const row = (Array.isArray(publicChannels?.channels) ? publicChannels.channels : []).find((item) =>
|
||||
String(item?.slug || '').trim().toLowerCase() === channelNameNormalized);
|
||||
if (row) channel = { channel: {
|
||||
ownerBlockchainName: row.ownerBlockchainName,
|
||||
channelRoot: { blockNumber: Number(row.rootBlockNumber), blockHash: normalizeRouteHash(row.rootBlockHashHex) },
|
||||
} };
|
||||
} catch { /* Public profile may be unavailable. */ }
|
||||
}
|
||||
const ownerBch = String(channel?.channel?.ownerBlockchainName || '').trim();
|
||||
const rootNo = Number(channel?.channel?.channelRoot?.blockNumber);
|
||||
const rootHash = normalizeRouteHash(channel?.channel?.channelRoot?.blockHash);
|
||||
@@ -1732,6 +1744,12 @@ export function render({ navigate, route, chrome }) {
|
||||
|
||||
clearContent();
|
||||
const channelOwner = extractLoginFromBlockchainName(selector?.channel?.ownerBlockchainName || focus?.channelInfo?.ownerBlockchainName || '');
|
||||
if (!state.session.isAuthorized) mountPublicChannelSidebar(screen, {
|
||||
owner: channelOwner,
|
||||
channel: resolvedChannelTitle,
|
||||
subscribers: payload?.channel?.subscribersCount ?? payload?.focus?.channelInfo?.subscribersCount ?? null,
|
||||
navigate,
|
||||
});
|
||||
const openPost = () => {
|
||||
const routeToChannel = buildChannelRouteFromThread(selector, resolvedChannelLabel);
|
||||
if (routeToChannel) navigate(routeToChannel);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -149,6 +149,11 @@ export function parseRouteFromPath(pathname = '') {
|
||||
if (segments.length >= baseOffset + 1) {
|
||||
const ownerBlockchainName = shineLogin;
|
||||
const channelName = decodePart(segments[baseOffset] || '');
|
||||
const streamMode = decodePart(segments[baseOffset + 1] || '').toLowerCase() === 's';
|
||||
const streamBlockNumber = streamMode ? decodePart(segments[baseOffset + 2] || '') : '';
|
||||
if (ownerBlockchainName && channelName && streamMode && /^[0-9]+$/.test(streamBlockNumber) && segments.length === baseOffset + 3) {
|
||||
return { pageId: 'channel-view', params: { ownerBlockchainName, channelName, channelId: '', scrollToMessageBlockNumber: streamBlockNumber } };
|
||||
}
|
||||
const messageBlockNumber = segments[baseOffset + 1] || '';
|
||||
if (ownerBlockchainName && channelName && messageBlockNumber) {
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { renderUserAvatar } from '../components/avatar-image.js';
|
||||
// Minimal public preview sidebar, shown only to visitors without a session.
|
||||
export function mountPublicChannelSidebar(screen, { owner = '', channel = '', subscribers = null, avatar = null, navigate }) {
|
||||
screen.querySelector('.shine-public-sidebar')?.remove();
|
||||
const panel = document.createElement('aside');
|
||||
panel.className = 'shine-public-sidebar';
|
||||
const identity = document.createElement('div');
|
||||
identity.className = 'shine-public-sidebar__identity';
|
||||
const face = document.createElement('span');
|
||||
face.className = 'shine-public-sidebar__face';
|
||||
face.replaceChildren(renderUserAvatar({ login: owner || 'unknown', size: 'sm' }));
|
||||
const details = document.createElement('div');
|
||||
const author = document.createElement('strong');
|
||||
author.textContent = owner || 'Автор';
|
||||
details.append(author);
|
||||
identity.append(face, details);
|
||||
const name = document.createElement('h2');
|
||||
name.textContent = channel || 'Канал';
|
||||
const count = document.createElement('p');
|
||||
count.textContent = subscribers == null ? '' : `${Math.max(0, Number(subscribers) || 0)} подписчиков`;
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'primary-btn';
|
||||
button.textContent = 'Открыть в SHiNE';
|
||||
button.addEventListener('click', () => {
|
||||
window.sessionStorage.setItem('shine-public-return-path', window.location.pathname);
|
||||
navigate('login-view');
|
||||
});
|
||||
panel.append(identity, name, count, button);
|
||||
screen.append(panel);
|
||||
}
|
||||
@@ -73,13 +73,23 @@ export function makeShineChannelShortRoute({ ownerLogin = '', ownerBlockchainNam
|
||||
const cleanOwnerLogin = normalizeLogin(ownerLogin) || extractLoginFromBlockchainName(ownerBlockchainName);
|
||||
const chName = String(channelName || '').trim();
|
||||
if (!cleanOwnerLogin || !chName) return '';
|
||||
return `${encodeRoutePart(cleanOwnerLogin)}/${encodeRoutePart(chName)}`;
|
||||
return `${SHINE_ROUTE_SEGMENT}/${encodeRoutePart(cleanOwnerLogin)}/${encodeRoutePart(chName)}`;
|
||||
}
|
||||
|
||||
export function makeShineMessageRoute({ ownerLogin = '', messageBlockchainName = '', messageBlockNumber = '' }) {
|
||||
export function makeShineChannelStreamRoute({ ownerLogin = '', ownerBlockchainName = '', channelName = '', messageBlockNumber = '' }) {
|
||||
const base = makeShineChannelShortRoute({ ownerLogin, ownerBlockchainName, channelName });
|
||||
const no = String(messageBlockNumber || '').trim();
|
||||
return base && /^[0-9]+$/.test(no) ? `${base}/s/${no}` : '';
|
||||
}
|
||||
|
||||
export function makeShineMessageRoute({ ownerLogin = '', messageBlockchainName = '', messageBlockNumber = '', channelName = '', channelOwnerBlockchainName = '' }) {
|
||||
const msgBch = String(messageBlockchainName || '').trim();
|
||||
const msgNo = String(messageBlockNumber || '').trim();
|
||||
if (!msgBch || !msgNo) return '';
|
||||
if (channelName) {
|
||||
const base = makeShineChannelShortRoute({ ownerLogin, ownerBlockchainName: channelOwnerBlockchainName || msgBch, channelName });
|
||||
if (base) return `${base}/${encodeRoutePart(msgNo)}`;
|
||||
}
|
||||
return `${SHINE_ROUTE_SEGMENT}/${encodeRoutePart(msgBch)}/${encodeRoutePart(msgNo)}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -418,3 +418,13 @@
|
||||
}
|
||||
}
|
||||
.channel-about-tiles:empty { display: none; }
|
||||
|
||||
/* Guest-only public preview, inspired by compact channel web viewers. */
|
||||
.shine-public-sidebar { position:fixed; right:24px; top:110px; width:260px; box-sizing:border-box; padding:22px; border:1px solid var(--border-color, #ddd); border-radius:16px; background:var(--surface, #fff); z-index:5; display:flex; flex-direction:column; gap:14px; box-shadow:0 8px 30px #0000000c; }
|
||||
.shine-public-sidebar__identity { display:flex; align-items:center; gap:12px; overflow-wrap:anywhere; }
|
||||
.shine-public-sidebar__face { display:grid; place-items:center; width:44px; height:44px; border-radius:50%; background:#ececf3; color:#34343e; flex-shrink:0; font-weight:700; }
|
||||
.shine-public-sidebar h2 { margin:0; font-size:19px; overflow-wrap:anywhere; }
|
||||
.shine-public-sidebar p { margin:0; }
|
||||
.shine-public-sidebar .primary-btn { width:100%; }
|
||||
@media (min-width:1050px) { .channels-screen--channel:has(.shine-public-sidebar) .channel-feed, .channels-screen--thread:has(.shine-public-sidebar) .thread-block { max-width:calc(100% - 310px); } }
|
||||
@media (max-width:1049px) { .shine-public-sidebar { position:relative; inset:auto; order:-1; width:100%; margin-bottom:14px; } }
|
||||
|
||||
Reference in New Issue
Block a user