Обновить учёт поддержки, лайки и профиль перед MVP

This commit is contained in:
AidarKC
2026-12-02 00:01:51 +03:00
parent d05d9db8a2
commit af0beccb4a
21 changed files with 109 additions and 57 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ import { toUserMessage } from '../services/ui-error-texts.js';
import { bytesToBase58 } from '../services/crypto-utils.js';
import { loadEncryptedUserSecrets } from '../services/key-vault.js';
import { readShineUserPda, supportShineUserOnSolana } from '../services/shine-user-pda-service.js';
import { parseStarCents, splitStarCents, formatStars, starCentsToLamports, formatLamportsSol, hexHash32 } from '../services/shine-support-amount.js';
import { parseStarCents, splitStarCents, formatStars, formatExactStars, starCentsToLamports, formatLamportsSol, hexHash32 } from '../services/shine-support-amount.js';
import { transferSolLamports } from '../services/solana-wallet-service.js';
import { getStarsQuoteFromRpc } from '../services/shine-stars-pyth.js';
import { loadVerifiedSupportTotals, formatVerifiedSupportStars } from '../services/support-totals-service.js';
@@ -296,8 +296,8 @@ export function render({ navigate, route, chrome }) {
const cents = parseStarCents(amountEl?.value || '');
const parts = splitStarCents(cents);
const sol = starsQuote ? ` · ≈ ${formatLamportsSol(starCentsToLamports(cents, starsQuote.solUsdE8, starsQuote.usdtUsdE8))} SOL` : '';
if (splitEl) splitEl.textContent = `${t('screens.support_flow.recipient')}: ${formatStars(parts.author)} · ${t('screens.support_flow.fund')}: ${formatStars(parts.dao)}${sol}`;
} catch { if (splitEl) splitEl.textContent = 'Минимальная поддержка 0,10 ⭐'; }
if (splitEl) splitEl.textContent = `${t('screens.support_flow.recipient')}: ${formatExactStars(parts.author)} · ${t('screens.support_flow.fund')}: ${formatExactStars(parts.dao)}${sol}`;
} catch { if (splitEl) splitEl.textContent = 'Минимальная поддержка 0,1 ⭐'; }
};
void getStarsQuoteFromRpc({ solanaEndpoint: state.entrySettings.solanaServer }).then(v => { starsQuote = v; if (!disposed) renderSplit(); })
.catch(() => { if (splitEl && !disposed) splitEl.textContent = 'Курс временно недоступен'; });
+10 -1
View File
@@ -8,6 +8,7 @@ import { openBlockchainDetailsModal } from '../components/blockchain-details-dia
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
import { publicLikeCount, hasLikeStatistics } from '../services/public-like-count.js';
import { iconHtml } from '../components/ui-icon.js';
import { loadUserProfileCard } from '../services/user-connections.js';
import { consumeReplyEditorOnOpen, rememberChannelPosition, readChannelPosition, restoreChannelPosition } from '../services/channel-view-state.js';
import { attachMessageMenu } from '../components/message-menu.js';
import { createTopBar } from '../components/topbar.js';
@@ -802,6 +803,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
likeButton.className = 'ui-button channel-action-item channel-action-like thread-like-btn';
if (isLiked) likeButton.classList.add('is-liked');
likeButton.innerHTML = `
${handlers.viewerShining ? `<span class="channel-action-counter">${Number(node?.shiningLikesCount || 0)}</span>` : ''}
<span class="channel-action-icon" aria-hidden="true">${iconHtml('heart', isLiked)}</span>
<span class="channel-action-label">${isPending ? t('screens.channel_thread_view.text_062') : t('screens.channel_thread_view.text_063')}</span>
`;
@@ -1168,7 +1170,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
const like = document.createElement('button');
like.type = 'button';
like.className = `channel-action-item thread-comment__like${liked ? ' is-liked' : ''}`;
like.innerHTML = `${iconHtml('heart', liked)}`;
like.innerHTML = `${handlers.viewerShining ? `<span class="channel-action-counter">${Number(node?.shiningLikesCount || 0)}</span>` : ''}${iconHtml('heart', liked)}`;
like.setAttribute('aria-pressed', String(liked));
like.setAttribute('aria-label', `${liked ? t('dialogs.modals.channel_thread_view.label_026') : t('screens.channel_thread_view.text_067')}, ${likes}`);
like.addEventListener('click', async () => {
@@ -1571,6 +1573,7 @@ export function prefetchThreadPage(path) {
}
export function render({ navigate, route, chrome }) {
let viewerShining = false;
let selector = parseThreadSelector(route);
const channelDisplayName = resolveChannelDisplayName(selector?.channel);
const routeKey = selector?.publicationOrdinal
@@ -1653,6 +1656,7 @@ export function render({ navigate, route, chrome }) {
// Пришли по «Обсуждение» из ленты – после первой загрузки сразу открыть редактор ответа.
let openEditorOnLoad = consumeReplyEditorOnOpen(window.location.pathname);
const handlers = {
get viewerShining() { return viewerShining; },
onSupport: (node, target) => {
const rootNumber = selector?.channel?.channelRootBlockNumber;
const rootHash = String(selector?.channel?.channelRootBlockHash || '').trim();
@@ -2238,5 +2242,10 @@ export function render({ navigate, route, chrome }) {
};
void refresh();
if (state.session.login) void loadUserProfileCard(state.session.login).then((profile) => {
if (disposed) return;
viewerShining = profile?.shineStatus === 'shining';
if (viewerShining) void refresh();
}).catch(() => {});
return screen;
}
+13 -2
View File
@@ -9,6 +9,7 @@ import { openBlockchainDetailsModal } from '../components/blockchain-details-dia
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
import { publicLikeCount, hasLikeStatistics } from '../services/public-like-count.js';
import { iconHtml } from '../components/ui-icon.js';
import { loadUserProfileCard } from '../services/user-connections.js';
import { createOverflowDots } from '../components/overflow-dots.js';
import { rememberChannelPosition, readChannelPosition, requestReplyEditorOnOpen, restoreChannelPosition } from '../services/channel-view-state.js';
import { getPreviousTrackedPath, navigateUp, parseRouteFromPath, toPrettyPath } from '../router.js';
@@ -1784,6 +1785,7 @@ function openMessageLikesListModal({ navigate, messageRef, initialTab = 'shining
function renderPostCard(post, {
navigate,
selector,
viewerShining = false,
onToggleLike,
onReply,
onRating,
@@ -1997,6 +1999,7 @@ function renderPostCard(post, {
const isLiked = post.reactionState === 'liked';
if (isLiked) likeButton.classList.add('is-liked');
likeButton.innerHTML = `
${viewerShining ? `<span class="channel-action-counter">${Number(post.shiningLikesCount || 0)}</span>` : ''}
<span class="channel-action-icon" aria-hidden="true">${iconHtml('heart', isLiked)}</span>
<span class="channel-action-label">${isPending ? t('screens.channel_view.text_096') : t('screens.channel_view.text_097')}</span>
`;
@@ -2140,7 +2143,7 @@ function renderPostCard(post, {
const supportButton = document.createElement('button');
supportButton.type = 'button';
supportButton.className = 'ui-button channel-action-item channel-action-support';
supportButton.textContent = '♥ SOL';
supportButton.textContent = '⭐';
supportButton.title = t('screens.support_phase2.donate');
// Проверенные сервером суммы; если индексатор не готов, число не показываем.
if (post.messageRef?.blockNumber != null && post.messageRef?.blockHash) {
@@ -2148,7 +2151,7 @@ function renderPostCard(post, {
void loadVerifiedSupportTotals(selector).then((totals) => {
if (!totals || !supportButton.isConnected) return;
const formatted = formatVerifiedSupportStars(totals.messages.get(messageId));
if (formatted) supportButton.textContent = `♥ ${formatted}`;
if (formatted) supportButton.textContent = formatted;
});
}
@@ -2363,6 +2366,7 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
}
const row = renderPostCard(item.post, {
navigate,
viewerShining: handlers.viewerShining,
selector: channelData.selector,
onToggleLike: handlers.onToggleLike,
onReply: handlers.onReply,
@@ -2547,6 +2551,7 @@ function renderSkeleton(screen) {
}
export function render({ navigate, route, chrome }) {
let viewerShining = false;
const channelId = route.params.channelId || '';
const scrollToMessageOrdinal = route.params.scrollToMessageOrdinal || '';
const routeSelector = buildSelectorFromRoute(route, channelId);
@@ -3068,6 +3073,7 @@ export function render({ navigate, route, chrome }) {
}
clearContent();
const stopSeenTracking = renderBody(screen, navigate, routeKey, apiData, {
viewerShining,
chrome,
restorePosition,
scrollToMessageOrdinal,
@@ -3247,5 +3253,10 @@ export function render({ navigate, route, chrome }) {
};
void refresh();
if (state.session.login) void loadUserProfileCard(state.session.login).then((profile) => {
if (disposed) return;
viewerShining = profile?.shineStatus === 'shining';
if (viewerShining) void refresh();
}).catch(() => {});
return screen;
}
+2 -1
View File
@@ -5,7 +5,7 @@ import { state } from '../state.js';
import { attachProfileAvatarPreview } from '../components/profile-avatar-preview.js';
import { createTopBar } from '../components/topbar.js';
import { loadUserProfileCard } from '../services/user-connections.js';
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
import { profileCardHtml, profileTileHtml, attachProfileDetails } from '../components/profile-card.js';
import { openShareSheet } from '../components/share-sheet.js';
import { createErrorState, createLoadingState } from '../components/feedback.js';
import { makeSharedProfileRoute } from '../services/shine-routes.js';
@@ -64,6 +64,7 @@ export function render({ navigate, chrome }) {
].join(''),
});
attachProfileDetails(body);
attachSupportStats(body, { login: card.login || login, isActive: () => !disposed });
avatarPreview = attachProfileAvatarPreview(body.querySelector('.user-profile-avatar-slot'), card);
+2 -1
View File
@@ -10,7 +10,7 @@ import { createErrorState, createLoadingState } from '../components/feedback.js'
import { toUserMessage } from '../services/ui-error-texts.js';
import { makeProfileLinksRoute } from '../services/shine-routes.js';
import { navigateBack } from '../router.js';
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
import { profileCardHtml, profileTileHtml, attachProfileDetails } from '../components/profile-card.js';
import { iconHtml } from '../components/ui-icon.js';
export const pageMeta = { id: 'user', get title() { return t('screens.user_profile_view.text_001'); } };
@@ -72,6 +72,7 @@ export function render({ navigate, route, chrome }) {
])].join(''),
});
attachProfileDetails(body);
attachSupportStats(body, { login: card.login, isActive: () => !disposed });
syncRelationTile();