SHA256
Локализовать интерфейс SHiNE на русский и английский
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { appendShineMessageLinks } from '../services/shine-message-links.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
|
||||
@@ -40,7 +41,7 @@ import { parsePublicationOrdinal, publicationAtOrdinal, ordinalForPublication }
|
||||
import { dropPageData, pageDataAge, readPageData, writePageData } from '../services/page-data-cache.js';
|
||||
import { scrollNodeIntoContainer } from '../services/scroll-utils.js';
|
||||
|
||||
export const pageMeta = { id: 'channel-thread-view', title: 'Обсуждение', shellMode: { scrollbar: 'hidden', topFade: false, contentUnderTopbar: false, contentWidth: 'wide' } };
|
||||
export const pageMeta = { id: 'channel-thread-view', get title() { return t('screens.channel_thread_view.text_001'); }, shellMode: { scrollbar: 'hidden', topFade: false, contentUnderTopbar: false, contentWidth: 'wide' } };
|
||||
const MSG_SUBTYPE_TEXT_POST = 10;
|
||||
const MSG_SUBTYPE_TEXT_RATING = 30;
|
||||
const MSG_SUBTYPE_TEXT_ENTRYPOINT = 100;
|
||||
@@ -76,7 +77,7 @@ async function loadThreadAvatarSnapshot(login) {
|
||||
|
||||
function createThreadAvatar(login) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const title = cleanLogin ? `Профиль ${cleanLogin}` : '';
|
||||
const title = cleanLogin ? t('screens.channel_thread_view.text_097', { value1: cleanLogin }) : '';
|
||||
const avatarEl = renderUserAvatar({
|
||||
login: cleanLogin || 'unknown',
|
||||
size: 'sm',
|
||||
@@ -237,7 +238,7 @@ function resolveChannelDisplayName(channelSelector) {
|
||||
&& normalizeRouteHash(summary?.channel?.channelRoot?.blockHash) === rootHash
|
||||
));
|
||||
if (!found) return '';
|
||||
const label = `${found.channel?.ownerLogin || 'неизвестно'}/${found.channel?.channelName || 'канал'}`;
|
||||
const label = `${found.channel?.ownerLogin || t('screens.channel_thread_view.text_078')}/${found.channel?.channelName || t('screens.channel_thread_view.text_079')}`;
|
||||
rememberChannelTitle(label, found.channel);
|
||||
return label;
|
||||
}
|
||||
@@ -247,7 +248,7 @@ function resolveChannelHeadingFromNode(node) {
|
||||
const ownerBch = String(info?.ownerBlockchainName || '').trim();
|
||||
const rootBlockNumber = Number(info?.channelRoot?.blockNumber);
|
||||
if (!ownerBch || !Number.isFinite(rootBlockNumber) || rootBlockNumber < 0) return '';
|
||||
if (rootBlockNumber === 0) return 'История пользователя';
|
||||
if (rootBlockNumber === 0) return t('screens.channel_thread_view.text_058');
|
||||
|
||||
const label = resolveChannelDisplayName({
|
||||
ownerBlockchainName: ownerBch,
|
||||
@@ -256,20 +257,20 @@ function resolveChannelHeadingFromNode(node) {
|
||||
});
|
||||
const slashIndex = label.indexOf('/');
|
||||
const channelName = slashIndex >= 0 ? label.slice(slashIndex + 1).trim() : label.trim();
|
||||
if (!channelName) return 'Сообщение в канале';
|
||||
return `Сообщение в канале ${channelName}`;
|
||||
if (!channelName) return t('screens.channel_thread_view.text_059');
|
||||
return t('screens.channel_thread_view.text_098', { value1: channelName });
|
||||
}
|
||||
|
||||
function getChannelMessageTypeMeta(msgSubType) {
|
||||
switch (Number(msgSubType || 0)) {
|
||||
case MSG_SUBTYPE_TEXT_EXERCISE:
|
||||
return { label: 'Упражнение', actionable: true };
|
||||
return { label: t('screens.channel_thread_view.text_002'), actionable: true };
|
||||
case MSG_SUBTYPE_TEXT_SERVICE:
|
||||
return { label: 'Услуга', actionable: true };
|
||||
return { label: t('screens.channel_thread_view.text_003'), actionable: true };
|
||||
case MSG_SUBTYPE_TEXT_COURSE:
|
||||
return { label: 'Курс', actionable: true };
|
||||
return { label: t('screens.channel_thread_view.text_004'), actionable: true };
|
||||
case MSG_SUBTYPE_TEXT_ENTRYPOINT:
|
||||
return { label: 'Оглавление' };
|
||||
return { label: t('screens.channel_thread_view.text_005') };
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -456,8 +457,8 @@ 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 || 'нет в ответе сервера',
|
||||
publicKey: source.publicKey || source.authorPublicKey || 'нет в ответе сервера',
|
||||
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,
|
||||
};
|
||||
}
|
||||
@@ -468,26 +469,26 @@ function openBlockchainDetailsModal(details, { isActive = () => true } = {}) {
|
||||
root.innerHTML = `
|
||||
<div class="modal" id="thread-blockchain-details-modal">
|
||||
<div class="modal-card stack blockchain-details-card">
|
||||
<h3 class="modal-title">Данные блокчейна сообщения</h3>
|
||||
<p class="meta-muted">Это технические данные записи Сияния. По ним можно увидеть цепочку автора, номер записи, хэш и подпись, если она есть в ответе сервера.</p>
|
||||
<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>Автор</span><strong>${escapeHtml(details.authorLogin)}</strong>
|
||||
<span>Блокчейн</span><code>${escapeHtml(details.authorBlockchainName)}</code>
|
||||
<span>Номер записи</span><code>${escapeHtml(details.blockNumber)}</code>
|
||||
<span>Хэш</span><code>${escapeHtml(details.blockHash)}</code>
|
||||
<span>Тип</span><code>${escapeHtml(details.msgSubType)}</code>
|
||||
<span>Время</span><code>${escapeHtml(details.createdAtMs ? new Date(Number(details.createdAtMs)).toLocaleString('ru-RU') : '–')}</code>
|
||||
<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 ? new Date(Number(details.createdAtMs)).toLocaleString('ru-RU') : '–')}</code>
|
||||
<span>Public key</span><code>${escapeHtml(details.publicKey)}</code>
|
||||
<span>Подпись</span><code>${escapeHtml(details.signature)}</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">Текст записи</label>
|
||||
<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">Скопировать</button>
|
||||
<button class="secondary-btn" id="thread-blockchain-details-raw" type="button">Показать сырой блок</button>
|
||||
<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">Закрыть</button>
|
||||
<button class="secondary-btn" id="thread-blockchain-details-close" type="button">${t('dialogs.modals.channel_thread_view.label_013')}</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -497,7 +498,7 @@ function openBlockchainDetailsModal(details, { isActive = () => true } = {}) {
|
||||
root.querySelector('#thread-blockchain-details-copy')?.addEventListener('click', async () => {
|
||||
await copyTextToClipboard(rawText);
|
||||
if (!isActive()) return;
|
||||
showToast('Данные блокчейна скопированы');
|
||||
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');
|
||||
@@ -519,9 +520,9 @@ function openReplyModal({ onSubmit, mode = 'reply', isActive = () => true, conte
|
||||
const isRating = mode === 'rating';
|
||||
return openChannelEditor({
|
||||
id: 'thread-reply-modal',
|
||||
title: isRating ? 'Оценка' : 'Ответ',
|
||||
submitLabel: isRating ? 'Отправить' : 'Ответить',
|
||||
placeholder: isRating ? 'Напишите оценку' : 'Напишите ответ',
|
||||
title: isRating ? t('dialogs.remaining.pages.channel_thread_view.openreplymodal.otsenka') : t('dialogs.remaining.pages.channel_thread_view.openreplymodal.otvet'),
|
||||
submitLabel: isRating ? t('dialogs.remaining.pages.channel_thread_view.openreplymodal.otpravit') : t('dialogs.remaining.pages.channel_thread_view.openreplymodal.otvetit'),
|
||||
placeholder: isRating ? t('dialogs.remaining.pages.channel_thread_view.openreplymodal.napishite_otsenku') : t('dialogs.remaining.pages.channel_thread_view.openreplymodal.napishite_otvet'),
|
||||
context,
|
||||
key: `${draftKey}:${mode}`,
|
||||
isActive,
|
||||
@@ -544,15 +545,15 @@ function openRepostModal({ navigate, channels = [], onSubmit, isActive = () => t
|
||||
root.innerHTML = `
|
||||
<div class="modal" id="thread-repost-modal">
|
||||
<div class="modal-card stack">
|
||||
<h3 class="modal-title">Репост</h3>
|
||||
<label class="meta-muted" for="thread-repost-channel-select">Канал</label>
|
||||
<h3 class="modal-title">${t('dialogs.modals.channel_thread_view.label_015')}</h3>
|
||||
<label class="meta-muted" for="thread-repost-channel-select">${t('dialogs.modals.channel_thread_view.label_016')}</label>
|
||||
<select id="thread-repost-channel-select" class="input">${options}</select>
|
||||
<label class="meta-muted" for="thread-repost-comment">Комментарий</label>
|
||||
<textarea id="thread-repost-comment" class="input" rows="5" maxlength="2000" placeholder="Комментарий к репосту"></textarea>
|
||||
<label class="meta-muted" for="thread-repost-comment">${t('dialogs.modals.channel_thread_view.label_017')}</label>
|
||||
<textarea id="thread-repost-comment" class="input" rows="5" maxlength="2000" placeholder="${t('dialogs.modals.channel_thread_view.label_014')}"></textarea>
|
||||
<div class="meta-muted inline-error" id="thread-repost-error"></div>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" id="thread-repost-cancel" type="button">Отмена</button>
|
||||
<button class="primary-btn" id="thread-repost-submit" type="button">Опубликовать репост</button>
|
||||
<button class="secondary-btn" id="thread-repost-cancel" type="button">${t('dialogs.modals.channel_thread_view.label_018')}</button>
|
||||
<button class="primary-btn" id="thread-repost-submit" type="button">${t('dialogs.modals.channel_thread_view.label_019')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -570,7 +571,7 @@ function openRepostModal({ navigate, channels = [], onSubmit, isActive = () => t
|
||||
if (textEl) textEl.disabled = inFlight;
|
||||
if (submitEl) {
|
||||
submitEl.disabled = inFlight;
|
||||
submitEl.textContent = inFlight ? 'Публикуем...' : 'Опубликовать репост';
|
||||
submitEl.textContent = inFlight ? t('dialogs.modals.channel_thread_view.label_020') : t('dialogs.remaining.pages.channel_thread_view.openrepostmodal.opublikovat_repost');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -583,12 +584,12 @@ function openRepostModal({ navigate, channels = [], onSubmit, isActive = () => t
|
||||
if (inFlight) return;
|
||||
const idx = Number(selectEl?.value ?? -1);
|
||||
if (!Number.isFinite(idx) || idx < 0 || idx >= channels.length) {
|
||||
errorEl.textContent = 'Выберите канал для репоста.';
|
||||
errorEl.textContent = t('dialogs.modals.channel_thread_view.label_021');
|
||||
return;
|
||||
}
|
||||
const text = String(textEl?.value || '').trim();
|
||||
if (!text) {
|
||||
errorEl.textContent = 'Введите комментарий к репосту.';
|
||||
errorEl.textContent = t('dialogs.modals.channel_thread_view.label_022');
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
@@ -600,7 +601,7 @@ function openRepostModal({ navigate, channels = [], onSubmit, isActive = () => t
|
||||
} catch (error) {
|
||||
if (!isActive()) return;
|
||||
setBusy(false);
|
||||
errorEl.textContent = toUserMessage(error, 'Не удалось сделать репост.');
|
||||
errorEl.textContent = toUserMessage(error, t('dialogs.modals.channel_thread_view.label_023'));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -609,7 +610,7 @@ function openRepostModal({ navigate, channels = [], onSubmit, isActive = () => t
|
||||
if (textEl) textEl.focus();
|
||||
}
|
||||
|
||||
function openMessageHistoryModal({ versions = [], title = 'История изменений' }) {
|
||||
function openMessageHistoryModal({ versions = [], title = t('dialogs.remaining.pages.channel_thread_view.openmessagehistorymodal.istoriya_izmeneniy') }) {
|
||||
const root = document.getElementById('modal-root');
|
||||
const rows = Array.isArray(versions) ? versions : [];
|
||||
root.innerHTML = `
|
||||
@@ -618,7 +619,7 @@ function openMessageHistoryModal({ versions = [], title = 'История изм
|
||||
<h3 class="modal-title">${title}</h3>
|
||||
<div class="stack" id="thread-history-list"></div>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" id="thread-history-close" type="button">Закрыть</button>
|
||||
<button class="secondary-btn" id="thread-history-close" type="button">${t('dialogs.modals.channel_thread_view.label_013')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -630,9 +631,9 @@ function openMessageHistoryModal({ versions = [], title = 'История изм
|
||||
const row = document.createElement('div');
|
||||
row.className = 'card stack';
|
||||
const ts = Number(item?.createdAtMs || 0);
|
||||
const text = String(item?.text || '').trim() || 'удалено';
|
||||
const text = String(item?.text || '').trim() || t('dialogs.remaining.pages.channel_thread_view.openmessagehistorymodal.udaleno');
|
||||
row.innerHTML = `
|
||||
<strong>Версия ${index + 1}</strong>
|
||||
<strong>${t('dialogs.final.history.version', { version: index + 1 })}</strong>
|
||||
<div class="meta-muted">${ts > 0 ? new Date(ts).toLocaleString('ru-RU') : '–'}</div>
|
||||
<p class="channel-message-body">${text}</p>
|
||||
`;
|
||||
@@ -647,8 +648,8 @@ function openMessageHistoryModal({ versions = [], title = 'История изм
|
||||
|
||||
function openEditMessageModal({ initialText = '', allowEmptyText = false, onSave, isActive = () => true, draftKey }) {
|
||||
return openChannelEditor({
|
||||
id: 'thread-edit-modal', title: 'Редактирование', submitLabel: 'Сохранить',
|
||||
placeholder: 'Текст сообщения', initialText, allowEmptyText,
|
||||
id: 'thread-edit-modal', title: t('dialogs.remaining.pages.channel_thread_view.openeditmessagemodal.redaktirovanie'), submitLabel: t('dialogs.remaining.pages.channel_thread_view.openeditmessagemodal.sohranit'),
|
||||
placeholder: t('dialogs.remaining.pages.channel_thread_view.openeditmessagemodal.tekst_soobscheniya'), initialText, allowEmptyText,
|
||||
key: draftKey, allowAttachments: false, rawText: true, isActive,
|
||||
onSubmit: ({ text }) => onSave(text),
|
||||
});
|
||||
@@ -661,10 +662,10 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
&& String(node?.authorBlockchainName || '').trim().toLowerCase() === channelOwnerBlockchainName.trim().toLowerCase();
|
||||
if (isOwnerPost) card.classList.add('channel-message-card--owner');
|
||||
|
||||
const author = node?.authorLogin || 'автор';
|
||||
const author = node?.authorLogin || t('screens.channel_thread_view.text_082');
|
||||
const versions = Array.isArray(node?.versions) ? node.versions : [];
|
||||
const versionsTotal = Number(node?.versionsTotal || versions.length || 1);
|
||||
const text = resolveNodeText(node) || (versionsTotal > 1 ? 'удалено' : '(пусто)');
|
||||
const text = resolveNodeText(node) || (versionsTotal > 1 ? t('screens.channel_thread_view.text_060') : t('screens.channel_thread_view.text_061'));
|
||||
const likes = Number(node?.likesCount || 0);
|
||||
const primaryLikes = Number(node?.primaryLikesCount || 0);
|
||||
const shiningLikes = Number(node?.shiningLikesCount || 0);
|
||||
@@ -714,13 +715,13 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
const editedMarker = document.createElement('span');
|
||||
editedMarker.type = 'button';
|
||||
editedMarker.className = 'ui-button message-edited-marker';
|
||||
editedMarker.textContent = `изменено ${Math.max(1, versionsTotal - 1)}`;
|
||||
editedMarker.title = 'Открыть историю редактирования';
|
||||
editedMarker.textContent = t('screens.channel_thread_view.text_099', { value1: Math.max(1, versionsTotal - 1) });
|
||||
editedMarker.title = t('screens.channel_thread_view.text_006');
|
||||
editedMarker.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
animatePress(event.currentTarget);
|
||||
openMessageHistoryModal({
|
||||
title: `История #${localNumber}`,
|
||||
title: t('screens.channel_thread_view.text_100', { value1: localNumber }),
|
||||
versions,
|
||||
});
|
||||
});
|
||||
@@ -742,13 +743,13 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
if (threadsLayout && isOwnerPost) {
|
||||
const title = String(channel.title || author).trim();
|
||||
const channelAvatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
initials: (title[0] || t('screens.channel_thread_view.text_083')).toUpperCase(),
|
||||
avatar: (channel.avatarAr || channel.avatarSha256) ? { ar: channel.avatarAr, sha256Hex: channel.avatarSha256 } : null,
|
||||
authorLogin: author,
|
||||
size: 'xl',
|
||||
className: 'channel-profile-avatar channel-message-avatar avatar-plain',
|
||||
title,
|
||||
alt: 'Аватар канала',
|
||||
alt: t('screens.channel_thread_view.text_007'),
|
||||
});
|
||||
channelAvatar.style.setProperty('--channel-avatar-size', '36px');
|
||||
avatar.replaceWith(channelAvatar);
|
||||
@@ -782,12 +783,12 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
const deleted = document.createElement('button');
|
||||
deleted.type = 'button';
|
||||
deleted.className = 'ui-button deleted-message-pill';
|
||||
deleted.textContent = `Удалённое сообщение от ${author}`;
|
||||
deleted.title = 'Открыть историю изменений';
|
||||
deleted.textContent = t('screens.channel_thread_view.text_101', { value1: author });
|
||||
deleted.title = t('screens.channel_thread_view.text_008');
|
||||
deleted.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
openMessageHistoryModal({
|
||||
title: `История #${localNumber}`,
|
||||
title: t('screens.channel_thread_view.text_102', { value1: localNumber }),
|
||||
versions,
|
||||
});
|
||||
});
|
||||
@@ -807,7 +808,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
if (isRating) {
|
||||
const ratingBadge = document.createElement('span');
|
||||
ratingBadge.className = 'channel-message-kind-badge channel-message-kind-badge--rating';
|
||||
ratingBadge.textContent = 'Оценка';
|
||||
ratingBadge.textContent = t('dialogs.modals.channel_thread_view.label_024');
|
||||
card.append(ratingBadge);
|
||||
}
|
||||
const body = document.createElement('p');
|
||||
@@ -838,17 +839,17 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
if (isLiked) likeButton.classList.add('is-liked');
|
||||
likeButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">${iconHtml('heart', isLiked)}</span>
|
||||
<span class="channel-action-label">${isPending ? 'Лайк...' : 'Лайк'}</span>
|
||||
<span class="channel-action-label">${isPending ? t('screens.channel_thread_view.text_062') : t('screens.channel_thread_view.text_063')}</span>
|
||||
`;
|
||||
likeButton.setAttribute('aria-pressed', String(isLiked));
|
||||
setActionTitle(likeButton, isPending ? 'Лайк…' : `${isLiked ? 'Убрать отметку «Нравится»' : 'Нравится'}, ${likes}`);
|
||||
setActionTitle(likeButton, isPending ? t('screens.channel_thread_view.text_064') : `${isLiked ? t('screens.channel_thread_view.text_065') : t('screens.channel_thread_view.text_066')}, ${likes}`);
|
||||
likeButton.disabled = isPending;
|
||||
likeButton.addEventListener('click', async (event) => {
|
||||
event.stopPropagation();
|
||||
animatePress(event.currentTarget);
|
||||
if (isPending) return;
|
||||
likeButton.disabled = true;
|
||||
setActionTitle(likeButton, 'Лайк...');
|
||||
setActionTitle(likeButton, t('screens.channel_thread_view.text_037'));
|
||||
try {
|
||||
await handlers.onToggleLike(target, isLiked ? 'unlike' : 'like', node);
|
||||
} catch (error) {
|
||||
@@ -867,7 +868,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
likesStatsButton.type = 'button';
|
||||
likesStatsButton.className = 'ui-button channel-action-item channel-action-like-stats';
|
||||
likesStatsButton.textContent = String(Number(likes) || '');
|
||||
likesStatsButton.setAttribute('aria-label', `Посмотреть статистику лайков: ${likes}`);
|
||||
likesStatsButton.setAttribute('aria-label', t('screens.channel_thread_view.text_103', { value1: likes }));
|
||||
likesStatsButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
void showLikeStatistics({ counts: node });
|
||||
@@ -878,10 +879,10 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
replyButton.className = 'ui-button channel-action-item thread-reply-btn';
|
||||
replyButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">${iconHtml('message')}</span>
|
||||
<span class="channel-action-label">Ответить</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_120')}</span>
|
||||
<span class="channel-action-counter">${Number(replies) > 0 ? replies : ''}</span>
|
||||
`;
|
||||
setActionTitle(replyButton, 'Ответить');
|
||||
setActionTitle(replyButton, t('screens.channel_thread_view.text_038'));
|
||||
replyButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
animatePress(event.currentTarget);
|
||||
@@ -910,9 +911,9 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
shareButton.className = 'ui-button channel-action-item channel-action-share thread-share-btn';
|
||||
shareButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">${iconHtml('share')}</span>
|
||||
<span class="channel-action-label">Отправить</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_121')}</span>
|
||||
`;
|
||||
setActionTitle(shareButton, 'Отправить');
|
||||
setActionTitle(shareButton, t('screens.channel_thread_view.text_039'));
|
||||
shareButton.addEventListener('click', async (event) => {
|
||||
event.stopPropagation();
|
||||
animatePress(event.currentTarget);
|
||||
@@ -926,10 +927,10 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
discussionButton.className = 'ui-button channel-action-item channel-action-discussion';
|
||||
discussionButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">${iconHtml('message')}</span>
|
||||
<span class="channel-action-label">Обсуждение</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_122')}</span>
|
||||
<span class="channel-action-counter">${replies || ''}</span>
|
||||
`;
|
||||
setActionTitle(discussionButton, `Открыть обсуждение, ответов: ${replies}`);
|
||||
setActionTitle(discussionButton, t('screens.channel_thread_view.text_104', { value1: replies }));
|
||||
discussionButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
animatePress(event.currentTarget);
|
||||
@@ -942,9 +943,9 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
repostButton.className = 'ui-button channel-action-item channel-action-repost';
|
||||
repostButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">${iconHtml('repost')}</span>
|
||||
<span class="channel-action-label">Репост</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_123')}</span>
|
||||
`;
|
||||
setActionTitle(repostButton, 'Репост');
|
||||
setActionTitle(repostButton, t('screens.channel_thread_view.text_040'));
|
||||
repostButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
if (!REPOSTS_ENABLED) { notifyRepostSoon(); return; }
|
||||
@@ -952,11 +953,11 @@ 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);
|
||||
menuItems.unshift({ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
menuItems.unshift({ label: t('screens.channel_thread_view.text_009'), iconHtml: iconHtml('reply'), action: () => replyButton.click() });
|
||||
// Те же действия, что у ответов в обсуждении.
|
||||
menuItems.splice(1, 0, { label: 'Скопировать текст', iconHtml: iconHtml('copy'), action: async () => {
|
||||
try { await copyTextToClipboard(parsedText.text); showToast('Текст скопирован'); }
|
||||
catch { showToast('Не удалось скопировать', { kind: 'error' }); }
|
||||
menuItems.splice(1, 0, { label: t('screens.channel_thread_view.text_010'), iconHtml: iconHtml('copy'), action: async () => {
|
||||
try { await copyTextToClipboard(parsedText.text); showToast(t('screens.channel_thread_view.text_041')); }
|
||||
catch { showToast(t('screens.channel_thread_view.text_042'), { kind: 'error' }); }
|
||||
} });
|
||||
if (repostTarget) {
|
||||
const originalButton = document.createElement('button');
|
||||
@@ -964,9 +965,9 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
originalButton.className = 'ui-button channel-action-item';
|
||||
originalButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">↪</span>
|
||||
<span class="channel-action-label">Оригинал</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_124')}</span>
|
||||
`;
|
||||
setActionTitle(originalButton, 'Оригинал');
|
||||
setActionTitle(originalButton, t('screens.channel_thread_view.text_043'));
|
||||
originalButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
const ownerLogin = extractLoginFromBlockchainName(repostTarget.blockchainName);
|
||||
@@ -977,16 +978,16 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
messageBlockNumber: repostTarget.blockNumber,
|
||||
}));
|
||||
});
|
||||
menuItems.push({ label: 'Оригинал', action: () => originalButton.click() });
|
||||
menuItems.push({ label: t('screens.channel_thread_view.text_011'), action: () => originalButton.click() });
|
||||
}
|
||||
const detailsButton = document.createElement('button');
|
||||
detailsButton.type = 'button';
|
||||
detailsButton.className = 'ui-button channel-action-item';
|
||||
detailsButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">⛓</span>
|
||||
<span class="channel-action-label">Данные блокчейна</span>
|
||||
<span class="channel-action-label">${th('screens.channel_thread_view.text_125')}</span>
|
||||
`;
|
||||
setActionTitle(detailsButton, 'Данные блокчейна');
|
||||
setActionTitle(detailsButton, t('screens.channel_thread_view.text_044'));
|
||||
detailsButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
openBlockchainDetailsModal(buildBlockchainDetails({
|
||||
@@ -999,13 +1000,13 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
msgSubType,
|
||||
}), { isActive: handlers.isActive });
|
||||
});
|
||||
menuItems.push({ label: 'Данные блокчейна', action: () => detailsButton.click() });
|
||||
menuItems.push({ label: t('screens.channel_thread_view.text_012'), action: () => detailsButton.click() });
|
||||
if (isOwnMessage) {
|
||||
const editButton = document.createElement('button');
|
||||
editButton.type = 'button';
|
||||
editButton.className = 'ui-button channel-action-item';
|
||||
editButton.setAttribute('aria-label', 'Редактировать');
|
||||
editButton.title = 'Редактировать';
|
||||
editButton.setAttribute('aria-label', t('dialogs.modals.channel_thread_view.label_025'));
|
||||
editButton.title = t('screens.channel_thread_view.text_013');
|
||||
editButton.innerHTML = `
|
||||
<span class="channel-action-icon" aria-hidden="true">✏️</span>
|
||||
`;
|
||||
@@ -1021,19 +1022,19 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
onDelete: async () => handlers.onEdit(target, '', { isChannelPost, isDelete: true }),
|
||||
});
|
||||
});
|
||||
menuItems.unshift({ label: 'Редактировать', action: () => editButton.click() });
|
||||
menuItems.push({ label: 'Удалить', danger: true, action: async () => {
|
||||
menuItems.unshift({ label: t('screens.channel_thread_view.text_014'), action: () => editButton.click() });
|
||||
menuItems.push({ label: t('screens.channel_thread_view.text_015'), danger: true, action: async () => {
|
||||
if (!await confirmDialog({
|
||||
title: 'Удалить сообщение?',
|
||||
text: 'Сообщение скроется из ленты. Предыдущие версии останутся в блокчейне и в истории изменений.',
|
||||
confirmLabel: 'Удалить',
|
||||
title: t('dialogs.pages.channel_thread_view.title_001'),
|
||||
text: t('dialogs.pages.channel_thread_view.text_002'),
|
||||
confirmLabel: t('dialogs.pages.channel_thread_view.confirmLabel_003'),
|
||||
danger: true,
|
||||
})) return;
|
||||
try { await handlers.onEdit(target, '', { isChannelPost, isDelete: true }); }
|
||||
catch (error) { if (handlers.isActive()) showToast(toUserMessage(error, 'Не удалось удалить сообщение.'), { kind: 'error' }); }
|
||||
catch (error) { if (handlers.isActive()) showToast(toUserMessage(error, t('screens.channel_thread_view.text_045')), { kind: 'error' }); }
|
||||
} });
|
||||
}
|
||||
if (versionsTotal > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions: versions }) });
|
||||
if (versionsTotal > 1) menuItems.push({ label: t('screens.channel_thread_view.text_016'), action: () => openMessageHistoryModal({ versions: versions }) });
|
||||
attachMessageMenu(card, headRow, menuItems);
|
||||
if (isOwnerPost && !threadsLayout) {
|
||||
const meta = document.createElement('div');
|
||||
@@ -1107,7 +1108,7 @@ function nodeKey(node) {
|
||||
function renderComment({ node, parent, focus, channelOwner, handlers, nested = false, mention = false, identity = null }) {
|
||||
const target = buildTargetFromNode(node);
|
||||
const key = messageRefKey(target);
|
||||
const author = String(node?.authorLogin || 'автор');
|
||||
const author = String(node?.authorLogin || t('screens.channel_thread_view.text_084'));
|
||||
const parsed = parseMessageAttachments(resolveNodeText(node));
|
||||
const versions = Array.isArray(node?.versions) ? node.versions : [];
|
||||
const isOwn = Boolean(state.session.login) && author.toLowerCase() === String(state.session.login).toLowerCase();
|
||||
@@ -1119,7 +1120,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
const who = document.createElement('button');
|
||||
who.type = 'button';
|
||||
who.className = 'thread-comment__who';
|
||||
who.setAttribute('aria-label', `Профиль ${author}`);
|
||||
who.setAttribute('aria-label', t('screens.channel_thread_view.text_105', { value1: author }));
|
||||
who.append(identity?.avatar || renderUserAvatar({ login: author, size: nested ? 'xs' : 'sm', className: 'thread-comment__avatar avatar-plain' }));
|
||||
who.addEventListener('click', () => handlers.navigate(makeProfileRoute(author)));
|
||||
|
||||
@@ -1137,7 +1138,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
if (!identity && channelOwner && author.toLowerCase() === channelOwner.toLowerCase()) {
|
||||
const badge = document.createElement('span');
|
||||
badge.className = 'thread-comment__badge';
|
||||
badge.textContent = 'Автор';
|
||||
badge.textContent = t('dialogs.modals.channel_thread_view.label_003');
|
||||
head.append(badge);
|
||||
}
|
||||
const time = document.createElement('time');
|
||||
@@ -1152,7 +1153,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
to.className = 'thread-comment__mention';
|
||||
to.innerHTML = iconHtml('reply');
|
||||
to.append(String(parent.authorLogin || ''));
|
||||
to.setAttribute('aria-label', `Ответ для ${parent.authorLogin || ''}. Перейти к его комментарию`);
|
||||
to.setAttribute('aria-label', t('screens.channel_thread_view.text_106', { value1: parent.authorLogin || '' }));
|
||||
to.addEventListener('click', () => handlers.jumpTo(nodeKey(parent), key));
|
||||
main.append(to);
|
||||
}
|
||||
@@ -1182,7 +1183,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
like.className = `channel-action-item thread-comment__like${liked ? ' is-liked' : ''}`;
|
||||
like.innerHTML = `${iconHtml('heart', liked)}`;
|
||||
like.setAttribute('aria-pressed', String(liked));
|
||||
like.setAttribute('aria-label', `${liked ? 'Убрать отметку «Нравится»' : 'Нравится'}, ${likes}`);
|
||||
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 () => {
|
||||
like.disabled = true;
|
||||
try { await handlers.onToggleLike(target, liked ? 'unlike' : 'like', node); }
|
||||
@@ -1194,7 +1195,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
commentLikeStats.type = 'button';
|
||||
commentLikeStats.className = 'channel-action-item thread-comment__like-count';
|
||||
commentLikeStats.textContent = String(likes || '');
|
||||
commentLikeStats.setAttribute('aria-label', `Статистика лайков: ${likes}`);
|
||||
commentLikeStats.setAttribute('aria-label', t('screens.channel_thread_view.text_107', { value1: likes }));
|
||||
commentLikeStats.addEventListener('click', () => { void showLikeStatistics({ counts: node }); });
|
||||
|
||||
const replies = replyCountOf(node);
|
||||
@@ -1202,26 +1203,26 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
reply.type = 'button';
|
||||
reply.className = 'channel-action-item thread-comment__reply';
|
||||
reply.innerHTML = `${iconHtml('message')}<span>${replies || ''}</span>`;
|
||||
reply.setAttribute('aria-label', `Ответить ${author}`);
|
||||
reply.setAttribute('aria-label', t('screens.channel_thread_view.text_108', { value1: author }));
|
||||
reply.addEventListener('click', () => handlers.setReplyTo(node));
|
||||
|
||||
const more = document.createElement('button');
|
||||
more.type = 'button';
|
||||
more.className = 'channel-action-item thread-comment__more';
|
||||
more.innerHTML = iconHtml('more');
|
||||
more.setAttribute('aria-label', `Действия с комментарием ${author}`);
|
||||
more.setAttribute('aria-label', t('screens.channel_thread_view.text_109', { value1: author }));
|
||||
const menuItems = [
|
||||
{ label: 'Ответить', iconHtml: iconHtml('reply'), action: () => handlers.setReplyTo(node) },
|
||||
{ label: 'Поделиться комментарием', iconHtml: iconHtml('share'), action: () => handlers.shareComment(node) },
|
||||
{ label: 'Скопировать текст', iconHtml: iconHtml('copy'), action: async () => {
|
||||
try { await navigator.clipboard.writeText(parsed.text); showToast('Текст скопирован'); }
|
||||
catch { showToast('Не удалось скопировать', { kind: 'error' }); }
|
||||
{ label: t('screens.channel_thread_view.text_017'), iconHtml: iconHtml('reply'), action: () => handlers.setReplyTo(node) },
|
||||
{ label: t('screens.channel_thread_view.text_018'), iconHtml: iconHtml('share'), action: () => handlers.shareComment(node) },
|
||||
{ label: t('screens.channel_thread_view.text_019'), iconHtml: iconHtml('copy'), action: async () => {
|
||||
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: 'Данные публикации', 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 }) },
|
||||
];
|
||||
if (versions.length > 1) menuItems.push({ label: 'История изменений', action: () => openMessageHistoryModal({ versions }) });
|
||||
if (versions.length > 1) menuItems.push({ label: t('screens.channel_thread_view.text_021'), action: () => openMessageHistoryModal({ versions }) });
|
||||
if (isOwn) {
|
||||
menuItems.splice(1, 0, { label: 'Редактировать', iconHtml: iconHtml('edit'), action: () => openEditMessageModal({
|
||||
menuItems.splice(1, 0, { label: t('screens.channel_thread_view.text_022'), iconHtml: iconHtml('edit'), action: () => openEditMessageModal({
|
||||
isActive: handlers.isActive,
|
||||
draftKey: `edit:${key}`,
|
||||
initialText: parsed.text,
|
||||
@@ -1229,10 +1230,10 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
onSave: async (nextText) => handlers.onEdit(target, composeMessageWithAttachments(nextText, parsed.attachments), { isChannelPost: false }),
|
||||
onDelete: async () => handlers.onEdit(target, '', { isChannelPost: false, isDelete: true }),
|
||||
}) });
|
||||
menuItems.push({ divider: true }, { label: 'Удалить', danger: true, iconHtml: iconHtml('trash'), action: async () => {
|
||||
if (!await confirmDialog({ title: 'Удалить комментарий?', text: 'Он скроется из обсуждения. Прежние версии останутся в блокчейне.', confirmLabel: 'Удалить', danger: true })) return;
|
||||
menuItems.push({ divider: true }, { label: t('screens.channel_thread_view.text_023'), danger: true, iconHtml: iconHtml('trash'), action: async () => {
|
||||
if (!await confirmDialog({ title: t('dialogs.pages.channel_thread_view.title_004'), text: t('dialogs.pages.channel_thread_view.text_005'), confirmLabel: t('dialogs.pages.channel_thread_view.confirmLabel_006'), danger: true })) return;
|
||||
try { await handlers.onEdit(target, '', { isChannelPost: false, isDelete: true }); }
|
||||
catch (error) { if (handlers.isActive()) showToast(toUserMessage(error, 'Не удалось удалить комментарий.'), { kind: 'error' }); }
|
||||
catch (error) { if (handlers.isActive()) showToast(toUserMessage(error, t('screens.channel_thread_view.text_048')), { kind: 'error' }); }
|
||||
} });
|
||||
}
|
||||
const menu = createDropdownMenu({ anchorEl: more, items: menuItems });
|
||||
@@ -1243,14 +1244,14 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
share.type = 'button';
|
||||
share.className = 'channel-action-item thread-comment__share';
|
||||
share.innerHTML = iconHtml('share');
|
||||
share.setAttribute('aria-label', 'Поделиться комментарием');
|
||||
share.setAttribute('aria-label', t('dialogs.modals.channel_thread_view.label_027'));
|
||||
share.addEventListener('click', () => handlers.shareComment(node));
|
||||
|
||||
const repost = document.createElement('button');
|
||||
repost.type = 'button';
|
||||
repost.className = 'channel-action-item thread-comment__repost';
|
||||
repost.innerHTML = iconHtml('repost');
|
||||
repost.setAttribute('aria-label', 'Репост');
|
||||
repost.setAttribute('aria-label', t('dialogs.modals.channel_thread_view.label_015'));
|
||||
repost.addEventListener('click', () => (REPOSTS_ENABLED ? handlers.onRepost?.(target) : notifyRepostSoon()));
|
||||
|
||||
// Ряд действий как у записи канала: лайк, ответы, репост, поделиться.
|
||||
@@ -1302,7 +1303,7 @@ function renderReplyGroup(branch, { focus, channelOwner, handlers }) {
|
||||
deeper.type = 'button';
|
||||
deeper.className = 'thread-more thread-more--deeper';
|
||||
if (index >= THREAD_GROUP_VISIBLE_REPLIES) deeper.classList.add('is-collapsed');
|
||||
deeper.textContent = `Ответы на этот комментарий · ${unloaded}`;
|
||||
deeper.textContent = t('screens.channel_thread_view.text_110', { value1: unloaded });
|
||||
deeper.addEventListener('click', () => handlers.onOpenThread(buildTargetFromNode(node)));
|
||||
list.append(deeper);
|
||||
}
|
||||
@@ -1313,7 +1314,7 @@ function renderReplyGroup(branch, { focus, channelOwner, handlers }) {
|
||||
const expand = document.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'thread-more';
|
||||
expand.textContent = `Ещё ${hidden} ${pluralRu(hidden, 'ответ', 'ответа', 'ответов')}`;
|
||||
expand.textContent = t('screens.channel_thread_view.text_111', { value1: hidden, value2: pluralRu(hidden, t('dialogs.modals.channel_thread_view.label_028'), t('screens.channel_thread_view.text_126'), t('screens.channel_thread_view.text_127')) });
|
||||
expand.addEventListener('click', () => {
|
||||
list.classList.add('is-expanded');
|
||||
expand.remove();
|
||||
@@ -1347,7 +1348,7 @@ function renderDescendants(items, handlers, nextNumber, depth = 0, parent = null
|
||||
const context = document.createElement('p');
|
||||
context.className = 'thread-reply-context';
|
||||
const excerpt = parseMessageAttachments(resolveNodeText(parent)).text;
|
||||
context.textContent = `В ответ ${parent.authorLogin || 'автору'} · ${excerpt.slice(0, 100) || 'Вложение'}`;
|
||||
context.textContent = t('screens.channel_thread_view.text_112', { value1: parent.authorLogin || t('dialogs.modals.channel_thread_view.label_029'), value2: excerpt.slice(0, 100) || t('screens.channel_thread_view.text_085') });
|
||||
row.prepend(context);
|
||||
}
|
||||
wrap.append(row);
|
||||
@@ -1489,7 +1490,7 @@ async function loadThreadData(sel, cacheKey, isCurrent) {
|
||||
const rootNo = Number(channel?.channel?.channelRoot?.blockNumber);
|
||||
const rootHash = normalizeRouteHash(channel?.channel?.channelRoot?.blockHash);
|
||||
if (!ownerBch || !Number.isFinite(rootNo) || !ordinal) {
|
||||
throw new Error('Канал или сообщение не найдено.');
|
||||
throw new Error(t('screens.channel_thread_view.text_086'));
|
||||
}
|
||||
sel.channel = {
|
||||
ownerBlockchainName: ownerBch,
|
||||
@@ -1505,7 +1506,7 @@ async function loadThreadData(sel, cacheKey, isCurrent) {
|
||||
const blockNumber = Number(message?.messageRef?.blockNumber);
|
||||
const blockHash = normalizeMessageHash(message?.messageRef?.blockHash);
|
||||
if (!Number.isSafeInteger(blockNumber) || blockNumber < 0 || !blockHash) {
|
||||
throw new Error(`Публикация №${ordinal} не найдена в канале.`);
|
||||
throw new Error(t('screens.channel_thread_view.text_113', { value1: ordinal }));
|
||||
}
|
||||
resolvedMessage = {
|
||||
blockchainName: String(message?.authorBlockchainName || ownerBch),
|
||||
@@ -1541,7 +1542,7 @@ async function loadThreadData(sel, cacheKey, isCurrent) {
|
||||
resolvedChannelLabel = await resolveChannelDisplayNameFromServer(sel.channel);
|
||||
if (!isCurrent()) return null;
|
||||
}
|
||||
const resolvedChannelTitle = resolvedChannelLabel || String(sel?.channel?.ownerBlockchainName || '').trim() || 'неизвестно';
|
||||
const resolvedChannelTitle = resolvedChannelLabel || String(sel?.channel?.ownerBlockchainName || '').trim() || t('screens.channel_thread_view.text_087');
|
||||
const channelSlug = String(sel?.short?.channelName || (resolvedChannelLabel.includes('/') ? resolvedChannelLabel.split('/').slice(1).join('/') : '')).trim();
|
||||
let title = channelTitleByLabel.get(resolvedChannelTitle) || channelSlug || resolvedChannelTitle;
|
||||
let avatarAr = '';
|
||||
@@ -1618,7 +1619,7 @@ export function render({ navigate, route, chrome }) {
|
||||
threadHeaderText.className = 'topbar-identity__text';
|
||||
const threadHeaderTitle = document.createElement('span');
|
||||
threadHeaderTitle.className = 'topbar-identity__title';
|
||||
threadHeaderTitle.textContent = 'Обсуждение';
|
||||
threadHeaderTitle.textContent = t('dialogs.modals.channel_thread_view.label_030');
|
||||
const threadHeaderChannel = document.createElement('span');
|
||||
threadHeaderChannel.className = 'topbar-identity__sub';
|
||||
threadHeaderChannel.textContent = '…';
|
||||
@@ -1634,7 +1635,7 @@ export function render({ navigate, route, chrome }) {
|
||||
back: state.session.isAuthorized ? { label: '<', onClick: () => navigateUp(isChannelPage, resolveThreadBackRoute(selector, activeResolvedChannelLabel)) } : null,
|
||||
actions: [{
|
||||
label: '⋯',
|
||||
ariaLabel: 'Меню обсуждения',
|
||||
ariaLabel: t('screens.channel_thread_view.text_024'),
|
||||
className: 'thread-menu-btn',
|
||||
menu: { minWidth: 240, items: () => threadMenuActions?.() || [] },
|
||||
}],
|
||||
@@ -1647,7 +1648,7 @@ export function render({ navigate, route, chrome }) {
|
||||
statusBox.style.display = 'none';
|
||||
|
||||
const ensureActive = () => {
|
||||
if (disposed) throw new Error('Экран обсуждения уже закрыт.');
|
||||
if (disposed) throw new Error(t('screens.channel_thread_view.text_088'));
|
||||
};
|
||||
|
||||
const showStatus = (message) => {
|
||||
@@ -1667,7 +1668,7 @@ export function render({ navigate, route, chrome }) {
|
||||
if (!login || !storagePwd) {
|
||||
state.authReturnHash = window.location.pathname || '/channels';
|
||||
navigate('login-view');
|
||||
throw new Error('Для этого действия нужно войти');
|
||||
throw new Error(t('screens.channel_thread_view.text_089'));
|
||||
}
|
||||
return { login, storagePwd };
|
||||
};
|
||||
@@ -1686,7 +1687,7 @@ export function render({ navigate, route, chrome }) {
|
||||
return;
|
||||
}
|
||||
const actionKey = makeReactionActionKey(target);
|
||||
if (!actionKey) throw new Error('Некорректная ссылка на сообщение для реакции.');
|
||||
if (!actionKey) throw new Error(t('screens.channel_thread_view.text_090'));
|
||||
if (pendingReactionActions.has(actionKey)) return;
|
||||
|
||||
const accepted = await confirmLikeAction({ liked: action === 'unlike', counts });
|
||||
@@ -1723,7 +1724,7 @@ export function render({ navigate, route, chrome }) {
|
||||
ensureActive();
|
||||
pendingThreadScroll.set(routeKey, '__LAST_REPLY__');
|
||||
softHaptic(15);
|
||||
showToast('Ответ отправлен');
|
||||
showToast(t('screens.channel_thread_view.text_049'));
|
||||
showStatus('');
|
||||
void refresh();
|
||||
},
|
||||
@@ -1733,7 +1734,7 @@ export function render({ navigate, route, chrome }) {
|
||||
ensureActive();
|
||||
pendingThreadScroll.set(routeKey, '__LAST_REPLY__');
|
||||
softHaptic(15);
|
||||
showToast('Оценка отправлена');
|
||||
showToast(t('screens.channel_thread_view.text_050'));
|
||||
showStatus('');
|
||||
void refresh();
|
||||
},
|
||||
@@ -1760,7 +1761,7 @@ export function render({ navigate, route, chrome }) {
|
||||
})
|
||||
.filter(Boolean)
|
||||
.filter((item) => Number(item.channelTypeCode) !== 0 && String(item.channelName || '').trim().toLowerCase() !== 'stories');
|
||||
if (!channels.length) throw new Error('У вас пока нет каналов для репоста.');
|
||||
if (!channels.length) throw new Error(t('screens.channel_thread_view.text_091'));
|
||||
|
||||
openRepostModal({
|
||||
navigate,
|
||||
@@ -1776,7 +1777,7 @@ export function render({ navigate, route, chrome }) {
|
||||
});
|
||||
ensureActive();
|
||||
softHaptic(12);
|
||||
showToast('Репост опубликован');
|
||||
showToast(t('screens.channel_thread_view.text_051'));
|
||||
showStatus('');
|
||||
},
|
||||
});
|
||||
@@ -1784,18 +1785,18 @@ export function render({ navigate, route, chrome }) {
|
||||
onShare: async (target) => {
|
||||
try {
|
||||
const routePath = buildThreadRouteFromTarget(target, selector, focusOrdinal);
|
||||
if (!routePath) throw new Error('Не удалось подготовить ссылку на обсуждение.');
|
||||
if (!routePath) throw new Error(t('screens.channel_thread_view.text_092'));
|
||||
const result = await shareOrCopyLink({
|
||||
title: 'Сияние · Обсуждение',
|
||||
text: 'Сообщение из обсуждения в Сиянии',
|
||||
title: t('screens.channel_thread_view.text_025'),
|
||||
text: t('screens.channel_thread_view.text_068'),
|
||||
url: buildAbsoluteRouteUrl(routePath),
|
||||
});
|
||||
if (disposed) return;
|
||||
if (result === 'copied') showToast('Ссылка скопирована');
|
||||
if (result === 'shared') showToast('Ссылка передана');
|
||||
if (result === 'copied') showToast(t('screens.channel_thread_view.text_052'));
|
||||
if (result === 'shared') showToast(t('screens.channel_thread_view.text_053'));
|
||||
if (result === 'copied' || result === 'shared') softHaptic(10);
|
||||
} catch (error) {
|
||||
showStatus(toUserMessage(error, 'Не удалось транслировать ссылку.'));
|
||||
showStatus(toUserMessage(error, t('screens.channel_thread_view.text_054')));
|
||||
}
|
||||
},
|
||||
prefetchThread: (target) => {
|
||||
@@ -1805,17 +1806,17 @@ export function render({ navigate, route, chrome }) {
|
||||
onOpenThread: (target) => {
|
||||
const routePath = buildThreadRouteFromTarget(target, selector, focusOrdinal);
|
||||
if (!routePath) {
|
||||
showStatus('Не удалось определить ссылку на обсуждение.');
|
||||
showStatus(t('screens.channel_thread_view.text_128'));
|
||||
return;
|
||||
}
|
||||
navigate(routePath);
|
||||
},
|
||||
onActionError: (error, action) => {
|
||||
const fallback = action === 'unlike'
|
||||
? 'Не удалось убрать лайк.'
|
||||
? t('screens.channel_thread_view.text_069')
|
||||
: action === 'repost'
|
||||
? 'Не удалось сделать репост.'
|
||||
: 'Не удалось поставить лайк.';
|
||||
? t('screens.channel_thread_view.text_070')
|
||||
: t('screens.channel_thread_view.text_071');
|
||||
showStatus(toUserMessage(error, fallback));
|
||||
},
|
||||
onEdit: async (target, textValue, meta = {}) => {
|
||||
@@ -1830,7 +1831,7 @@ export function render({ navigate, route, chrome }) {
|
||||
});
|
||||
ensureActive();
|
||||
softHaptic(12);
|
||||
showToast('Сообщение обновлено');
|
||||
showToast(t('screens.channel_thread_view.text_055'));
|
||||
showStatus('');
|
||||
void refresh();
|
||||
},
|
||||
@@ -1878,7 +1879,7 @@ export function render({ navigate, route, chrome }) {
|
||||
const focus = payload?.focus || null;
|
||||
const descendants = Array.isArray(payload?.descendants) ? payload.descendants : [];
|
||||
const totalReplies = totalRepliesOfPayload(payload);
|
||||
const resolvedChannelTitle = resolvedChannelLabel || String(selector?.channel?.ownerBlockchainName || '').trim() || 'неизвестно';
|
||||
const resolvedChannelTitle = resolvedChannelLabel || String(selector?.channel?.ownerBlockchainName || '').trim() || t('screens.channel_thread_view.text_093');
|
||||
const channelOwner = extractLoginFromBlockchainName(selector?.channel?.ownerBlockchainName || focus?.channelInfo?.ownerBlockchainName || selector?.short?.ownerBlockchainName || '');
|
||||
const shortName = String(selector?.short?.channelName || channelSlug).trim();
|
||||
const visibleOwner = channelOwner || extractLoginFromBlockchainName(selector?.short?.ownerBlockchainName || '');
|
||||
@@ -1889,17 +1890,17 @@ export function render({ navigate, route, chrome }) {
|
||||
threadHeaderChannel.textContent = formatChannelAddress({ ownerLogin: visibleOwner, channelName: shortName });
|
||||
threadHeaderButton.querySelector('.channel-thread-header-avatar')?.remove();
|
||||
const avatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
initials: (title[0] || t('screens.channel_thread_view.text_094')).toUpperCase(),
|
||||
avatar: (avatarAr || avatarSha256) ? { ar: avatarAr, sha256Hex: avatarSha256 } : null,
|
||||
authorLogin: visibleOwner,
|
||||
size: 'xl',
|
||||
className: 'channel-profile-avatar channel-thread-header-avatar avatar-plain',
|
||||
title,
|
||||
alt: 'Аватар канала',
|
||||
alt: t('screens.channel_thread_view.text_026'),
|
||||
});
|
||||
avatar.style.setProperty('--channel-avatar-size', '40px');
|
||||
threadHeaderButton.prepend(avatar);
|
||||
threadHeaderButton.title = 'Открыть канал';
|
||||
threadHeaderButton.title = t('screens.channel_thread_view.text_027');
|
||||
threadHeaderButton.disabled = false;
|
||||
threadHeaderButton.onclick = (event) => {
|
||||
event.preventDefault();
|
||||
@@ -1919,16 +1920,16 @@ export function render({ navigate, route, chrome }) {
|
||||
threadMenuActions = () => {
|
||||
const muted = isThreadMuted(routeKey);
|
||||
return [
|
||||
{ label: 'Перейти к записи', iconHtml: iconHtml('doc'), action: openPost },
|
||||
{ label: muted ? 'Уведомлять об ответах' : 'Не уведомлять об ответах', iconHtml: iconHtml(muted ? 'bell' : 'bell-off'), action: () => {
|
||||
{ label: t('screens.channel_thread_view.text_028'), iconHtml: iconHtml('doc'), action: openPost },
|
||||
{ label: muted ? t('screens.channel_thread_view.text_072') : t('screens.channel_thread_view.text_073'), iconHtml: iconHtml(muted ? 'bell' : 'bell-off'), action: () => {
|
||||
setThreadMuted(routeKey, !muted);
|
||||
showToast(muted ? 'Уведомления об ответах включены' : 'Ответы в этом обсуждении не будут приходить в уведомления');
|
||||
showToast(muted ? t('screens.channel_thread_view.text_074') : t('screens.channel_thread_view.text_075'));
|
||||
} },
|
||||
{ label: 'Поделиться записью', iconHtml: iconHtml('share'), action: () => {
|
||||
{ label: t('screens.channel_thread_view.text_029'), iconHtml: iconHtml('share'), action: () => {
|
||||
if (!focusTarget) return;
|
||||
openShareSheet({
|
||||
title: 'Поделиться записью',
|
||||
kicker: `${resolvedChannelTitle} · запись`,
|
||||
title: t('screens.channel_thread_view.text_030'),
|
||||
kicker: t('screens.channel_thread_view.text_114', { value1: resolvedChannelTitle }),
|
||||
text: parseMessageAttachments(resolveNodeText(focus)).text,
|
||||
url: buildAbsoluteRouteUrl(buildThreadRouteFromTarget(focusTarget, selector, focusOrdinal)),
|
||||
});
|
||||
@@ -1941,8 +1942,8 @@ export function render({ navigate, route, chrome }) {
|
||||
jumpTo: () => {},
|
||||
setReplyTo: (node) => handlers.openReplyEditor(node),
|
||||
shareComment: (node) => openShareSheet({
|
||||
title: 'Поделиться',
|
||||
kicker: `${node.authorLogin} · запись`,
|
||||
title: t('screens.channel_thread_view.text_031'),
|
||||
kicker: t('screens.channel_thread_view.text_115', { value1: node.authorLogin }),
|
||||
text: parseMessageAttachments(resolveNodeText(node)).text,
|
||||
url: buildAbsoluteRouteUrl(buildThreadRouteFromTarget(buildTargetFromNode(node), selector, null)),
|
||||
}),
|
||||
@@ -1957,13 +1958,13 @@ export function render({ navigate, route, chrome }) {
|
||||
let identity = null;
|
||||
if (isChannelPost) {
|
||||
const avatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
initials: (title[0] || t('screens.channel_thread_view.text_095')).toUpperCase(),
|
||||
avatar: (avatarAr || avatarSha256) ? { ar: avatarAr, sha256Hex: avatarSha256 } : null,
|
||||
authorLogin: node?.authorLogin,
|
||||
size: 'xl',
|
||||
className: 'channel-profile-avatar thread-comment__avatar avatar-plain',
|
||||
title,
|
||||
alt: 'Аватар канала',
|
||||
alt: t('screens.channel_thread_view.text_032'),
|
||||
});
|
||||
avatar.style.setProperty('--channel-avatar-size', '36px');
|
||||
identity = { title, avatar };
|
||||
@@ -1992,7 +1993,7 @@ export function render({ navigate, route, chrome }) {
|
||||
listWrap.className = 'thread-block thread-block--replies';
|
||||
const listTitle = document.createElement('h3');
|
||||
listTitle.className = 'thread-section-title';
|
||||
listTitle.textContent = `Комментарии · ${Math.max(totalReplies, comments.length)}`;
|
||||
listTitle.textContent = t('screens.channel_thread_view.text_116', { value1: Math.max(totalReplies, comments.length) });
|
||||
listWrap.append(listTitle);
|
||||
|
||||
// Возврат к ответу после перехода по цитате
|
||||
@@ -2000,7 +2001,7 @@ export function render({ navigate, route, chrome }) {
|
||||
returnBtn.type = 'button';
|
||||
returnBtn.className = 'thread-return';
|
||||
returnBtn.hidden = true;
|
||||
returnBtn.textContent = 'Вернуться к ответу';
|
||||
returnBtn.textContent = t('dialogs.modals.channel_thread_view.label_031');
|
||||
let returnKey = '';
|
||||
const highlight = (el) => {
|
||||
screen.querySelectorAll('.thread-comment.is-highlight').forEach((x) => x.classList.remove('is-highlight'));
|
||||
@@ -2025,8 +2026,8 @@ export function render({ navigate, route, chrome }) {
|
||||
returnBtn.hidden = false;
|
||||
},
|
||||
shareComment: (node) => openShareSheet({
|
||||
title: 'Поделиться комментарием',
|
||||
kicker: `${node.authorLogin} · комментарий`,
|
||||
title: t('screens.channel_thread_view.text_033'),
|
||||
kicker: t('screens.channel_thread_view.text_117', { value1: node.authorLogin }),
|
||||
text: parseMessageAttachments(resolveNodeText(node)).text,
|
||||
// Ссылка ведёт на обсуждение самого комментария – так же он открывается нажатием.
|
||||
url: buildAbsoluteRouteUrl(buildThreadRouteFromTarget(buildTargetFromNode(node), selector, null)),
|
||||
@@ -2042,7 +2043,7 @@ export function render({ navigate, route, chrome }) {
|
||||
} else {
|
||||
const empty = document.createElement('div');
|
||||
empty.className = 'empty-note thread-empty';
|
||||
empty.textContent = 'Пока нет комментариев. Можно начать разговор.';
|
||||
empty.textContent = t('dialogs.modals.channel_thread_view.label_032');
|
||||
listWrap.append(empty);
|
||||
}
|
||||
screen.append(listWrap, returnBtn);
|
||||
@@ -2065,18 +2066,18 @@ export function render({ navigate, route, chrome }) {
|
||||
author: String(node?.authorLogin || ''),
|
||||
time: formatShortAge(node?.createdAtMs),
|
||||
text: parsedNode.text,
|
||||
attachmentLabel: parsedNode.attachments.length ? 'Вложение' : '',
|
||||
attachmentLabel: parsedNode.attachments.length ? t('screens.channel_thread_view.text_076') : '',
|
||||
};
|
||||
if (isChannelPost) {
|
||||
item.title = title;
|
||||
item.avatar = renderAvatar({
|
||||
initials: (title[0] || 'К').toUpperCase(),
|
||||
initials: (title[0] || t('screens.channel_thread_view.text_096')).toUpperCase(),
|
||||
avatar: (avatarAr || avatarSha256) ? { ar: avatarAr, sha256Hex: avatarSha256 } : null,
|
||||
authorLogin: item.author,
|
||||
size: 'xl',
|
||||
className: 'channel-profile-avatar avatar-plain',
|
||||
title,
|
||||
alt: 'Аватар канала',
|
||||
alt: t('screens.channel_thread_view.text_034'),
|
||||
});
|
||||
item.avatar.style.setProperty('--channel-avatar-size', '40px');
|
||||
}
|
||||
@@ -2096,9 +2097,9 @@ export function render({ navigate, route, chrome }) {
|
||||
const chain = [...ancestors, focus, ...path].filter(Boolean).map(chainItem);
|
||||
openChannelEditor({
|
||||
id: 'thread-reply-modal',
|
||||
title: 'Ответ',
|
||||
submitLabel: 'Ответить',
|
||||
placeholder: `Ответить ${replyTargetName(node)}…`,
|
||||
title: t('screens.channel_thread_view.text_035'),
|
||||
submitLabel: t('screens.channel_thread_view.text_077'),
|
||||
placeholder: t('screens.channel_thread_view.text_118', { value1: replyTargetName(node) }),
|
||||
context: { chain },
|
||||
key: `thread-reply:${nodeKey(node)}`,
|
||||
openAttachOnStart: attach,
|
||||
@@ -2121,19 +2122,19 @@ export function render({ navigate, route, chrome }) {
|
||||
const field = document.createElement('button');
|
||||
field.type = 'button';
|
||||
field.className = 'thread-reply-bar__field';
|
||||
field.textContent = `Ответьте ${replyTargetName(focus)}…`;
|
||||
field.textContent = t('screens.channel_thread_view.text_119', { value1: replyTargetName(focus) });
|
||||
field.addEventListener('click', () => replyEditorOpener(focus));
|
||||
const attach = document.createElement('button');
|
||||
attach.type = 'button';
|
||||
attach.className = 'thread-reply-bar__icon';
|
||||
attach.innerHTML = iconHtml('image');
|
||||
attach.setAttribute('aria-label', 'Ответ с фото, видео или файлом');
|
||||
attach.setAttribute('aria-label', t('dialogs.modals.channel_thread_view.label_033'));
|
||||
attach.addEventListener('click', () => replyEditorOpener(focus, { attach: true }));
|
||||
const expand = document.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'thread-reply-bar__icon';
|
||||
expand.innerHTML = iconHtml('expand');
|
||||
expand.setAttribute('aria-label', 'Открыть редактор ответа');
|
||||
expand.setAttribute('aria-label', t('dialogs.modals.channel_thread_view.label_034'));
|
||||
expand.addEventListener('click', () => replyEditorOpener(focus));
|
||||
open.append(me, field, attach, expand);
|
||||
} else {
|
||||
@@ -2142,7 +2143,7 @@ export function render({ navigate, route, chrome }) {
|
||||
open.append(loginBtn);
|
||||
open.className = 'thread-reply-guest';
|
||||
loginBtn.className = 'primary-btn channel-main-action';
|
||||
loginBtn.textContent = 'Войти, чтобы ответить';
|
||||
loginBtn.textContent = t('dialogs.modals.channel_thread_view.label_035');
|
||||
loginBtn.addEventListener('click', () => { state.authReturnHash = window.location.pathname || '/channels'; navigate('login-view'); });
|
||||
}
|
||||
bar.append(open);
|
||||
@@ -2177,7 +2178,7 @@ export function render({ navigate, route, chrome }) {
|
||||
if (!sel) {
|
||||
const invalid = document.createElement('div');
|
||||
invalid.className = 'card meta-muted';
|
||||
invalid.textContent = 'Обсуждение не найдено: неверная ссылка.';
|
||||
invalid.textContent = t('dialogs.modals.channel_thread_view.label_036');
|
||||
screen.append(invalid);
|
||||
return;
|
||||
}
|
||||
@@ -2207,7 +2208,7 @@ export function render({ navigate, route, chrome }) {
|
||||
threadHeaderButton.disabled = true;
|
||||
threadHeaderButton.onclick = null;
|
||||
threadHeaderButton.querySelector('.channel-thread-header-avatar')?.remove();
|
||||
threadHeaderTitle.textContent = 'Обсуждение';
|
||||
threadHeaderTitle.textContent = t('dialogs.modals.channel_thread_view.label_030');
|
||||
}
|
||||
const skeleton = shown ? null : renderSkeleton(screen);
|
||||
|
||||
@@ -2225,11 +2226,11 @@ export function render({ navigate, route, chrome }) {
|
||||
} catch (error) {
|
||||
if (disposed || seq !== refreshSeq) return;
|
||||
skeleton?.remove();
|
||||
if (shown) { showStatus(toUserMessage(error, 'Не удалось обновить обсуждение.')); return; }
|
||||
if (shown) { showStatus(toUserMessage(error, t('screens.channel_thread_view.text_056'))); return; }
|
||||
threadHeaderChannel.textContent = '';
|
||||
screen.append(createLoadErrorCard({
|
||||
title: 'Не удалось загрузить обсуждение',
|
||||
message: toUserMessage(error, 'Проверьте подключение и повторите попытку.'),
|
||||
title: t('screens.channel_thread_view.text_036'),
|
||||
message: toUserMessage(error, t('screens.channel_thread_view.text_057')),
|
||||
onRetry: () => void refresh(),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user