SHA256
Добавить систему поддержки SHiNE
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { openShineSupportDialog } from '../components/shine-support-dialog.js';
|
||||
import { hexHash32 } from '../services/shine-support-amount.js';
|
||||
import { loadVerifiedSupportTotals, formatVerifiedSupportLamports } 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';
|
||||
@@ -2155,9 +2158,42 @@ function renderPostCard(post, {
|
||||
if (!REPOSTS_ENABLED) { notifyRepostSoon(); return; }
|
||||
void onRepost?.(post.messageRef);
|
||||
});
|
||||
// Support posts through the verified on-chain 90/10 flow (separate from likes).
|
||||
const supportButton = document.createElement('button');
|
||||
supportButton.type = 'button';
|
||||
supportButton.className = 'ui-button channel-action-item channel-action-support';
|
||||
supportButton.textContent = '♥ SOL';
|
||||
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 = formatVerifiedSupportLamports(totals.messages.get(messageId));
|
||||
if (formatted) supportButton.textContent = `♥ ${formatted}`;
|
||||
});
|
||||
}
|
||||
|
||||
supportButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
const messageRef = post.messageRef;
|
||||
const rootHash = String(selector?.channelRootBlockHash || '');
|
||||
const msgHash = String(messageRef?.blockHash || '');
|
||||
const recipient = String(post.authorLogin || '').trim();
|
||||
if (!recipient || !/^[0-9a-f]{64}$/i.test(rootHash) || !/^[0-9a-f]{64}$/i.test(msgHash)) {
|
||||
showToast(t('screens.support_phase2.invalid_target'), { kind: 'error' });
|
||||
return;
|
||||
}
|
||||
openShineSupportDialog({ recipientLogin: recipient, target: {
|
||||
type: 2,
|
||||
channelBlockNumber: BigInt(selector.channelRootBlockNumber), channelBlockHash: hexHash32(rootHash),
|
||||
messageBlockNumber: BigInt(messageRef.blockNumber), messageBlockHash: hexHash32(msgHash),
|
||||
} });
|
||||
});
|
||||
// Четыре кнопки как в Threads: лайк, ответы, репост, поделиться.
|
||||
if (threadsLayout) actions.append(likeButton, ...(Number(post.likesCount) > 0 ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(Number(post.likesCount) > 0 ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
actions.append(supportButton);
|
||||
if (selector?.publicOrdinalUrlsAllowed && post.messageRef?.blockNumber != null) {
|
||||
const streamRoute = makeShineChannelStreamRoute({
|
||||
ownerBlockchainName: selector?.ownerBlockchainName,
|
||||
|
||||
Reference in New Issue
Block a user