Проверить вложения и блоки в каналах

This commit is contained in:
AidarKC
2026-11-21 00:24:25 +03:00
parent 859dbee1f1
commit 792f368175
27 changed files with 786 additions and 137 deletions
+4 -49
View File
@@ -4,6 +4,7 @@ import { formatDateTime } from '../i18n/format.js';
import { t, th } from '../i18n/index.js';
import { appendShineMessageLinks } from '../services/shine-message-links.js';
import { confirmDialog } from '../components/confirm-dialog.js';
import { openBlockchainDetailsModal } from '../components/blockchain-details-dialog.js';
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
import { iconHtml } from '../components/ui-icon.js';
import { consumeReplyEditorOnOpen, rememberChannelPosition, readChannelPosition, restoreChannelPosition } from '../services/channel-view-state.js';
@@ -460,56 +461,10 @@ function buildBlockchainDetails({ target, authorLogin, timestampMs, text, raw, l
msgSubType: msgSubType ?? source.msgSubType ?? '',
createdAtMs: timestampMs || source.createdAtMs || '',
text: String(text || ''),
signature: source.signature || source.blockSignature || source.authorSignature || t('screens.channel_thread_view.text_080'),
publicKey: source.publicKey || source.authorPublicKey || t('screens.channel_thread_view.text_081'),
raw,
};
}
function openBlockchainDetailsModal(details, { isActive = () => true } = {}) {
const root = document.getElementById('modal-root');
const rawText = JSON.stringify(details.raw || details, null, 2);
root.innerHTML = `
<div class="modal" id="thread-blockchain-details-modal">
<div class="modal-card stack blockchain-details-card">
<h3 class="modal-title">${t('dialogs.modals.channel_thread_view.label_001')}</h3>
<p class="meta-muted">${t('dialogs.modals.channel_thread_view.label_002')}</p>
<div class="blockchain-details-grid">
<span>${t('dialogs.modals.channel_thread_view.label_003')}</span><strong>${escapeHtml(details.authorLogin)}</strong>
<span>${t('dialogs.modals.channel_thread_view.label_004')}</span><code>${escapeHtml(details.authorBlockchainName)}</code>
<span>${t('dialogs.modals.channel_thread_view.label_005')}</span><code>${escapeHtml(details.blockNumber)}</code>
<span>${t('dialogs.modals.channel_thread_view.label_006')}</span><code>${escapeHtml(details.blockHash)}</code>
<span>${t('dialogs.modals.channel_thread_view.label_007')}</span><code>${escapeHtml(details.msgSubType)}</code>
<span>${t('dialogs.modals.channel_thread_view.label_008')}</span><code>${escapeHtml(details.createdAtMs ? formatDateTime(new Date(Number(details.createdAtMs))) : '–')}</code>
<span>Public key</span><code>${escapeHtml(details.publicKey)}</code>
<span>${t('dialogs.modals.channel_thread_view.label_009')}</span><code>${escapeHtml(details.signature)}</code>
</div>
<label class="field-label" for="thread-blockchain-details-text">${t('dialogs.modals.channel_thread_view.label_010')}</label>
<textarea class="input" id="thread-blockchain-details-text" rows="4" readonly>${escapeHtml(details.text)}</textarea>
<pre class="blockchain-raw-block" id="thread-blockchain-raw-block" hidden>${escapeHtml(rawText)}</pre>
<div class="form-actions-grid">
<button class="secondary-btn" id="thread-blockchain-details-copy" type="button">${t('dialogs.modals.channel_thread_view.label_011')}</button>
<button class="secondary-btn" id="thread-blockchain-details-raw" type="button">${t('dialogs.modals.channel_thread_view.label_012')}</button>
</div>
<button class="secondary-btn" id="thread-blockchain-details-close" type="button">${t('dialogs.modals.channel_thread_view.label_013')}</button>
</div>
</div>
`;
root.querySelector('#thread-blockchain-details-close')?.addEventListener('click', () => {
root.innerHTML = '';
});
root.querySelector('#thread-blockchain-details-copy')?.addEventListener('click', async () => {
await copyTextToClipboard(rawText);
if (!isActive()) return;
showToast(t('dialogs.remaining.pages.channel_thread_view.openblockchaindetailsmodal.dannye_blokcheyna_skopirovany'));
});
root.querySelector('#thread-blockchain-details-raw')?.addEventListener('click', () => {
const rawEl = root.querySelector('#thread-blockchain-raw-block');
if (!rawEl) return;
rawEl.hidden = !rawEl.hidden;
});
}
function resolveNodeText(node) {
return firstNonEmptyText(
latestVersionText(node?.versions),
@@ -1020,7 +975,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
raw: node,
localNumber,
msgSubType,
}), { isActive: handlers.isActive });
}), { isActive: handlers.isActive, authService, solanaEndpoint: state.entrySettings.solanaServer });
});
menuItems.push({ label: t('screens.channel_thread_view.text_012'), action: () => detailsButton.click() });
if (isOwnMessage) {
@@ -1255,7 +1210,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
try { await navigator.clipboard.writeText(parsed.text); showToast(t('screens.channel_thread_view.text_046')); }
catch { showToast(t('screens.channel_thread_view.text_047'), { kind: 'error' }); }
} },
{ label: t('screens.channel_thread_view.text_020'), iconHtml: iconHtml('info'), action: () => openBlockchainDetailsModal(buildBlockchainDetails({ target, authorLogin: author, timestampMs: node?.createdAtMs, text: resolveNodeText(node), raw: node, localNumber: 0, msgSubType: Number(node?.msgSubType || 0) }), { isActive: handlers.isActive }) },
{ label: t('screens.channel_thread_view.text_020'), iconHtml: iconHtml('info'), action: () => openBlockchainDetailsModal(buildBlockchainDetails({ target, authorLogin: author, timestampMs: node?.createdAtMs, text: resolveNodeText(node), raw: node, localNumber: 0, msgSubType: Number(node?.msgSubType || 0) }), { isActive: handlers.isActive, authService, solanaEndpoint: state.entrySettings.solanaServer }) },
];
if (versions.length > 1) menuItems.push({ label: t('screens.channel_thread_view.text_021'), action: () => openMessageHistoryModal({ versions }) });
if (isOwn) {
@@ -1893,7 +1848,7 @@ export function render({ navigate, route, chrome }) {
const modalRoot = document.getElementById('modal-root');
if (!modalRoot) return;
if (modalRoot.querySelector([
'#thread-blockchain-details-modal',
'#blockchain-details-modal',
'#thread-edit-modal',
'#thread-history-modal',
'#thread-reply-modal',
+2 -47
View File
@@ -5,6 +5,7 @@ import { formatDateTime, getIntlLocale } from '../i18n/format.js';
import { t, th } from '../i18n/index.js';
import { appendShineMessageLinks } from '../services/shine-message-links.js';
import { confirmDialog } from '../components/confirm-dialog.js';
import { openBlockchainDetailsModal } from '../components/blockchain-details-dialog.js';
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
import { iconHtml } from '../components/ui-icon.js';
import { createOverflowDots } from '../components/overflow-dots.js';
@@ -850,56 +851,10 @@ function buildBlockchainDetails({ messageRef, authorLogin, timestampMs, text, ra
msgSubType: msgSubType ?? source.msgSubType ?? '',
createdAtMs: timestampMs || source.createdAtMs || '',
text: String(text || ''),
signature: source.signature || source.blockSignature || source.authorSignature || t('screens.channel_view.text_114'),
publicKey: source.publicKey || source.authorPublicKey || t('screens.channel_view.text_115'),
raw,
};
}
function openBlockchainDetailsModal(details, { isActive = () => true } = {}) {
const root = document.getElementById('modal-root');
const rawText = JSON.stringify(details.raw || details, null, 2);
root.innerHTML = `
<div class="modal" id="blockchain-details-modal">
<div class="modal-card stack blockchain-details-card">
<h3 class="modal-title">${t('dialogs.modals.channel_view.label_011')}</h3>
<p class="meta-muted">${t('dialogs.modals.channel_view.label_012')}</p>
<div class="blockchain-details-grid">
<span>${t('dialogs.modals.channel_view.label_013')}</span><strong>${escapeHtml(details.authorLogin)}</strong>
<span>${t('dialogs.modals.channel_view.label_014')}</span><code>${escapeHtml(details.authorBlockchainName)}</code>
<span>${t('dialogs.modals.channel_view.label_015')}</span><code>${escapeHtml(details.blockNumber)}</code>
<span>${t('dialogs.modals.channel_view.label_016')}</span><code>${escapeHtml(details.blockHash)}</code>
<span>${t('dialogs.modals.channel_view.label_017')}</span><code>${escapeHtml(details.msgSubType)}</code>
<span>${t('dialogs.modals.channel_view.label_018')}</span><code>${escapeHtml(details.createdAtMs ? formatDateTime(new Date(Number(details.createdAtMs))) : '–')}</code>
<span>Public key</span><code>${escapeHtml(details.publicKey)}</code>
<span>${t('dialogs.modals.channel_view.label_019')}</span><code>${escapeHtml(details.signature)}</code>
</div>
<label class="field-label" for="blockchain-details-text">${t('dialogs.modals.channel_view.label_020')}</label>
<textarea class="input" id="blockchain-details-text" rows="4" readonly>${escapeHtml(details.text)}</textarea>
<pre class="blockchain-raw-block" id="blockchain-raw-block" hidden>${escapeHtml(rawText)}</pre>
<div class="form-actions-grid">
<button class="secondary-btn" id="blockchain-details-copy" type="button">${t('dialogs.modals.channel_view.label_021')}</button>
<button class="secondary-btn" id="blockchain-details-raw" type="button">${t('dialogs.modals.channel_view.label_022')}</button>
</div>
<button class="secondary-btn" id="blockchain-details-close" type="button">${t('dialogs.modals.channel_view.label_005')}</button>
</div>
</div>
`;
root.querySelector('#blockchain-details-close')?.addEventListener('click', () => {
root.innerHTML = '';
});
root.querySelector('#blockchain-details-copy')?.addEventListener('click', async () => {
await copyTextToClipboard(rawText);
if (!isActive()) return;
showToast(t('dialogs.remaining.pages.channel_view.openblockchaindetailsmodal.dannye_blokcheyna_skopirovany'));
});
root.querySelector('#blockchain-details-raw')?.addEventListener('click', () => {
const rawEl = root.querySelector('#blockchain-raw-block');
if (!rawEl) return;
rawEl.hidden = !rawEl.hidden;
});
}
function renderDraftAttachments(container, attachments) {
if (!container) return;
container.innerHTML = '';
@@ -2259,7 +2214,7 @@ function renderPostCard(post, {
raw: post.rawMessage,
localNumber: post.localNumber,
msgSubType: post.msgSubType,
}), { isActive });
}), { isActive, authService, solanaEndpoint: state.entrySettings.solanaServer });
});
menuItems.push({ label: t('screens.channel_view.text_034'), iconHtml: iconHtml('info'), action: () => detailsButton.click() });
if (post.isOwnMessage) {