SHA256
Добавить систему поддержки SHiNE
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { openShineSupportDialog } from '../components/shine-support-dialog.js';
|
||||
import { hexHash32 } from '../services/shine-support-amount.js';
|
||||
import { formatDateTime } from '../i18n/format.js';
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { appendShineMessageLinks } from '../services/shine-message-links.js';
|
||||
@@ -954,6 +956,14 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
});
|
||||
if (threadsLayout) actions.append(likeButton, ...(likes > 0 ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(likes > 0 ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
const supportBtn = document.createElement('button');
|
||||
supportBtn.type = 'button';
|
||||
supportBtn.className = 'ui-button channel-action-item channel-action-support';
|
||||
supportBtn.textContent = '♥ SOL';
|
||||
supportBtn.title = t('screens.support_phase2.donate');
|
||||
supportBtn.addEventListener('click', (event) => { event.stopPropagation(); handlers.onSupport?.(node, target); });
|
||||
|
||||
actions.append(supportBtn);
|
||||
menuItems.unshift({ label: t('screens.channel_thread_view.text_009'), iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
// Те же действия, что у ответов в обсуждении.
|
||||
menuItems.splice(1, 0, { label: t('screens.channel_thread_view.text_010'), iconHtml: iconHtml('copy'), action: async () => {
|
||||
@@ -1257,6 +1267,14 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
|
||||
// Ряд действий как у записи канала: лайк, ответы, репост, поделиться.
|
||||
actions.append(like, ...(likes > 0 ? [commentLikeStats] : []), reply, repost, share);
|
||||
const supportBtn = document.createElement('button');
|
||||
supportBtn.type = 'button';
|
||||
supportBtn.className = 'channel-action-item thread-comment__support';
|
||||
supportBtn.textContent = '♥ SOL';
|
||||
supportBtn.title = t('screens.support_phase2.donate');
|
||||
supportBtn.addEventListener('click', (event) => { event.stopPropagation(); handlers.onSupport?.(node, target); });
|
||||
actions.append(supportBtn);
|
||||
|
||||
main.append(actions);
|
||||
item.append(who, main);
|
||||
// Как в Threads: нажатие на ответ открывает его обсуждение (кнопки, ссылки и вложения работают сами по себе).
|
||||
@@ -1678,6 +1696,21 @@ export function render({ navigate, route, chrome }) {
|
||||
// Пришли по «Обсуждение» из ленты – после первой загрузки сразу открыть редактор ответа.
|
||||
let openEditorOnLoad = consumeReplyEditorOnOpen(window.location.pathname);
|
||||
const handlers = {
|
||||
onSupport: (node, target) => {
|
||||
const rootNumber = selector?.channel?.channelRootBlockNumber;
|
||||
const rootHash = String(selector?.channel?.channelRootBlockHash || '').trim();
|
||||
const messageHash = String(target?.blockHash || '').trim();
|
||||
const recipientLogin = String(node?.authorLogin || '').trim();
|
||||
if (!recipientLogin || !Number.isSafeInteger(Number(rootNumber))
|
||||
|| !/^[0-9a-f]{64}$/i.test(rootHash) || !/^[0-9a-f]{64}$/i.test(messageHash)) {
|
||||
showToast(t('screens.support_phase2.invalid_target'), { kind: 'error' });
|
||||
return;
|
||||
}
|
||||
openShineSupportDialog({ recipientLogin, target: {
|
||||
type: 2, channelBlockNumber: BigInt(rootNumber), channelBlockHash: hexHash32(rootHash),
|
||||
messageBlockNumber: BigInt(target.blockNumber), messageBlockHash: hexHash32(messageHash),
|
||||
} });
|
||||
},
|
||||
navigate,
|
||||
isActive: () => !disposed,
|
||||
openReplyEditor: (node) => replyEditorOpener?.(node),
|
||||
|
||||
Reference in New Issue
Block a user