Исправить отображение и учёт поддержки сообщений

This commit is contained in:
AidarKC
2026-12-02 02:13:01 +03:00
parent 7cf0170de7
commit a9fa1cd2a2
11 changed files with 110 additions and 63 deletions
+5 -11
View File
@@ -1,6 +1,6 @@
import { openShineSupportDialog } from '../components/shine-support-dialog.js';
import { hexHash32 } from '../services/shine-support-amount.js';
import { loadVerifiedSupportTotals, formatVerifiedSupportStars } from '../services/support-totals-service.js';
import { formatVerifiedSupportStars } from '../services/support-totals-service.js';
import { formatDateTime, getIntlLocale } from '../i18n/format.js';
import { t, th } from '../i18n/index.js';
import { appendShineMessageLinks } from '../services/shine-message-links.js';
@@ -1260,6 +1260,7 @@ function mapApiMessageToPost(message, selector, localNumber) {
likesCount: Number(message?.likesCount || 0),
primaryLikesCount: Number(message?.primaryLikesCount || 0),
shiningLikesCount: Number(message?.shiningLikesCount || 0),
supportStarCents: String(message?.supportStarCents || '0'),
repliesCount: Number(message?.repliesCount || 0),
// Кто недавно ответил — для миниатюр у счётчика обсуждения. Сервер пока не отдаёт (см. docs/UI-Design).
recentRepliers: Array.isArray(message?.recentRepliers) ? message.recentRepliers.slice(0, 2) : [],
@@ -1999,7 +2000,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>` : ''}
${viewerShining && Number(post.shiningLikesCount || 0) > 0 ? `<span class="channel-action-counter">${Number(post.shiningLikesCount)}</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>
`;
@@ -2145,15 +2146,8 @@ function renderPostCard(post, {
supportButton.className = 'ui-button channel-action-item channel-action-support';
supportButton.textContent = '⭐';
supportButton.title = t('screens.support_phase2.donate');
// Проверенные сервером суммы; если индексатор не готов, число не показываем.
if (post.messageRef?.blockNumber != null && post.messageRef?.blockHash) {
const messageId = `${String(post.messageRef.blockNumber)}:${String(post.messageRef.blockHash).toLowerCase()}`;
void loadVerifiedSupportTotals(selector).then((totals) => {
if (!totals || !supportButton.isConnected) return;
const formatted = formatVerifiedSupportStars(totals.messages.get(messageId));
if (formatted) supportButton.textContent = formatted;
});
}
const supportCount = formatVerifiedSupportStars(post.supportStarCents);
if (supportCount) supportButton.textContent = supportCount;
supportButton.addEventListener('click', (event) => {
event.stopPropagation();