SHA256
Локализовать интерфейс SHiNE на русский и английский
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import { authService } from '../state.js';
|
||||
import { KeyRotationClient } from '../services/key-rotation-service.js';
|
||||
@@ -5,66 +6,66 @@ import { inspectBlockchainDataItem } from '../services/blockchain-entry-inspecto
|
||||
import { makeProfileRoute, makeShineChannelRoute, makeShineMessageRoute } from '../services/shine-routes.js';
|
||||
import { actionErrorText } from '../services/ui-error-texts.js';
|
||||
|
||||
export const pageMeta = { id: 'my-blockchain-view', title: 'Мой блокчейн' };
|
||||
export const pageMeta = { id: 'my-blockchain-view', get title() { return t('screens.my_blockchain_view.text_001'); } };
|
||||
|
||||
const PROFILE_LABELS = new Map([
|
||||
['first_name', 'Имя'],
|
||||
['last_name', 'Фамилия'],
|
||||
['address', 'Адрес'],
|
||||
['web', 'Ссылки'],
|
||||
['phone', 'Телефон'],
|
||||
['about', 'О себе'],
|
||||
['spiritual_path', 'Духовный путь'],
|
||||
['account_role', 'Тип аккаунта'],
|
||||
['shine', 'Сияние'],
|
||||
['gender', 'Пол'],
|
||||
['ava', 'Аватар'],
|
||||
const PROFILE_LABELS = () => new Map([
|
||||
['first_name', t('screens.my_blockchain_view.text_108')],
|
||||
['last_name', t('screens.my_blockchain_view.text_109')],
|
||||
['address', t('screens.my_blockchain_view.text_110')],
|
||||
['web', t('screens.my_blockchain_view.text_111')],
|
||||
['phone', t('screens.my_blockchain_view.text_112')],
|
||||
['about', t('screens.my_blockchain_view.text_113')],
|
||||
['spiritual_path', t('screens.my_blockchain_view.text_114')],
|
||||
['account_role', t('screens.my_blockchain_view.text_115')],
|
||||
['shine', t('screens.my_blockchain_view.text_116')],
|
||||
['gender', t('screens.my_blockchain_view.text_117')],
|
||||
['ava', t('screens.my_blockchain_view.text_118')],
|
||||
]);
|
||||
|
||||
const CONNECTION_LABELS = new Map([
|
||||
[10, ['Добавлен близкий друг', 'Близкий друг']],
|
||||
[11, ['Удалён из близких друзей', 'Близкий друг']],
|
||||
[14, ['Добавлен друг', 'Друг']],
|
||||
[15, ['Удалён из друзей', 'Друг']],
|
||||
[20, ['Добавлен контакт', 'Контакт']],
|
||||
[21, ['Удалён из контактов', 'Контакт']],
|
||||
[30, ['Оформлена подписка', 'Подписка']],
|
||||
[31, ['Подписка отменена', 'Подписка']],
|
||||
[40, ['Добавлена связь «супруг/супруга»', 'Супруг/супруга']],
|
||||
[41, ['Удалена связь «супруг/супруга»', 'Супруг/супруга']],
|
||||
[50, ['Добавлена связь «родитель»', 'Родитель']],
|
||||
[51, ['Удалена связь «родитель»', 'Родитель']],
|
||||
[52, ['Добавлена связь «ребёнок»', 'Ребёнок']],
|
||||
[53, ['Удалена связь «ребёнок»', 'Ребёнок']],
|
||||
[54, ['Добавлена связь «брат/сестра»', 'Брат/сестра']],
|
||||
[55, ['Удалена связь «брат/сестра»', 'Брат/сестра']],
|
||||
[60, ['Устаревшая отметка знакомства', 'Legacy-связь']],
|
||||
[61, ['Устаревшая отмена отметки знакомства', 'Legacy-связь']],
|
||||
[70, ['Подтверждён сияющий пользователь', 'Подтверждение сияния']],
|
||||
[71, ['Снято подтверждение сияния', 'Подтверждение сияния']],
|
||||
[74, ['Отмечен как замеченный сияющим', 'Отметка сияния']],
|
||||
[75, ['Снята отметка «видел сияющим»', 'Отметка сияния']],
|
||||
[80, ['Подтверждён официальный аккаунт', 'Официальный аккаунт']],
|
||||
[81, ['Снято подтверждение официального аккаунта', 'Официальный аккаунт']],
|
||||
const CONNECTION_LABELS = () => new Map([
|
||||
[10, [t('screens.my_blockchain_view.text_119'), t('screens.my_blockchain_view.text_120')]],
|
||||
[11, [t('screens.my_blockchain_view.text_121'), t('screens.my_blockchain_view.text_122')]],
|
||||
[14, [t('screens.my_blockchain_view.text_123'), t('screens.my_blockchain_view.text_124')]],
|
||||
[15, [t('screens.my_blockchain_view.text_125'), t('screens.my_blockchain_view.text_126')]],
|
||||
[20, [t('screens.my_blockchain_view.text_127'), t('screens.my_blockchain_view.text_128')]],
|
||||
[21, [t('screens.my_blockchain_view.text_129'), t('screens.my_blockchain_view.text_130')]],
|
||||
[30, [t('screens.my_blockchain_view.text_131'), t('screens.my_blockchain_view.text_132')]],
|
||||
[31, [t('screens.my_blockchain_view.text_133'), t('screens.my_blockchain_view.text_134')]],
|
||||
[40, [t('screens.my_blockchain_view.text_135'), t('screens.my_blockchain_view.text_136')]],
|
||||
[41, [t('screens.my_blockchain_view.text_137'), t('screens.my_blockchain_view.text_138')]],
|
||||
[50, [t('screens.my_blockchain_view.text_139'), t('screens.my_blockchain_view.text_140')]],
|
||||
[51, [t('screens.my_blockchain_view.text_141'), t('screens.my_blockchain_view.text_142')]],
|
||||
[52, [t('screens.my_blockchain_view.text_143'), t('screens.my_blockchain_view.text_144')]],
|
||||
[53, [t('screens.my_blockchain_view.text_145'), t('screens.my_blockchain_view.text_146')]],
|
||||
[54, [t('screens.my_blockchain_view.text_147'), t('screens.my_blockchain_view.text_148')]],
|
||||
[55, [t('screens.my_blockchain_view.text_149'), t('screens.my_blockchain_view.text_150')]],
|
||||
[60, [t('screens.my_blockchain_view.text_151'), t('screens.my_blockchain_view.text_152')]],
|
||||
[61, [t('screens.my_blockchain_view.text_153'), t('screens.my_blockchain_view.text_154')]],
|
||||
[70, [t('screens.my_blockchain_view.text_155'), t('screens.my_blockchain_view.text_156')]],
|
||||
[71, [t('screens.my_blockchain_view.text_157'), t('screens.my_blockchain_view.text_158')]],
|
||||
[74, [t('screens.my_blockchain_view.text_159'), t('screens.my_blockchain_view.text_160')]],
|
||||
[75, [t('screens.my_blockchain_view.text_161'), t('screens.my_blockchain_view.text_162')]],
|
||||
[80, [t('screens.my_blockchain_view.text_163'), t('screens.my_blockchain_view.text_164')]],
|
||||
[81, [t('screens.my_blockchain_view.text_165'), t('screens.my_blockchain_view.text_166')]],
|
||||
]);
|
||||
|
||||
const STATUS_LABELS = new Map([
|
||||
[10, 'Упражнение выполнено один раз'],
|
||||
[20, 'Упражнение изучено'],
|
||||
[30, 'Услуга / процедура пройдена'],
|
||||
[100, 'Статус подтверждён'],
|
||||
[110, 'Отмечен интерес к курсу'],
|
||||
[120, 'Курс начат'],
|
||||
[130, 'Курс изучается'],
|
||||
[140, 'Курс заброшен'],
|
||||
[150, 'Курс завершён'],
|
||||
const STATUS_LABELS = () => new Map([
|
||||
[10, t('screens.my_blockchain_view.text_167')],
|
||||
[20, t('screens.my_blockchain_view.text_168')],
|
||||
[30, t('screens.my_blockchain_view.text_169')],
|
||||
[100, t('screens.my_blockchain_view.text_170')],
|
||||
[110, t('screens.my_blockchain_view.text_171')],
|
||||
[120, t('screens.my_blockchain_view.text_172')],
|
||||
[130, t('screens.my_blockchain_view.text_173')],
|
||||
[140, t('screens.my_blockchain_view.text_174')],
|
||||
[150, t('screens.my_blockchain_view.text_175')],
|
||||
]);
|
||||
|
||||
const FORK_REASON_LABELS = new Map([
|
||||
[1, 'Обычная смена ключей'],
|
||||
[2, 'Возможная компрометация'],
|
||||
[3, 'Откат после подтверждённой компрометации'],
|
||||
[4, 'Восстановление доступа'],
|
||||
const FORK_REASON_LABELS = () => new Map([
|
||||
[1, t('screens.my_blockchain_view.text_176')],
|
||||
[2, t('screens.my_blockchain_view.text_177')],
|
||||
[3, t('screens.my_blockchain_view.text_178')],
|
||||
[4, t('screens.my_blockchain_view.text_179')],
|
||||
]);
|
||||
|
||||
function shortHash(value) {
|
||||
@@ -94,20 +95,20 @@ function previewText(value) {
|
||||
function profileValueLabel(key, value) {
|
||||
const clean = String(value || '').trim();
|
||||
if (key === 'account_role') {
|
||||
if (clean === 'primary') return 'Основной аккаунт';
|
||||
if (clean === 'non_voting') return 'Не учитывать мой голос';
|
||||
if (clean === 'primary') return t('screens.my_blockchain_view.text_030');
|
||||
if (clean === 'non_voting') return t('screens.my_blockchain_view.text_031');
|
||||
}
|
||||
if (key === 'shine') {
|
||||
if (clean === 'shining' || clean === 'yes') return 'Сияющий';
|
||||
if (clean === 'not_interested') return 'Сияние неинтересно';
|
||||
if (clean === 'unknown') return 'Неизвестно';
|
||||
if (clean === 'shining' || clean === 'yes') return t('screens.my_blockchain_view.text_032');
|
||||
if (clean === 'not_interested') return t('screens.my_blockchain_view.text_033');
|
||||
if (clean === 'unknown') return t('screens.my_blockchain_view.text_034');
|
||||
}
|
||||
if (key === 'gender') {
|
||||
if (clean === 'male') return 'Мужской';
|
||||
if (clean === 'female') return 'Женский';
|
||||
if (clean === 'unknown') return 'Не указан';
|
||||
if (clean === 'male') return t('screens.my_blockchain_view.text_035');
|
||||
if (clean === 'female') return t('screens.my_blockchain_view.text_036');
|
||||
if (clean === 'unknown') return t('screens.my_blockchain_view.text_037');
|
||||
}
|
||||
if (key === 'ava') return 'Изменена аватарка';
|
||||
if (key === 'ava') return t('screens.my_blockchain_view.text_038');
|
||||
return clean;
|
||||
}
|
||||
|
||||
@@ -115,8 +116,8 @@ function targetText(target) {
|
||||
if (!target) return '';
|
||||
const login = String(target.toLogin || '').trim();
|
||||
const block = Number(target.toBlockNumber);
|
||||
if (login && Number.isInteger(block) && block >= 0) return `${login} · блок #${block}`;
|
||||
if (Number.isInteger(block) && block >= 0) return `блок #${block}`;
|
||||
if (login && Number.isInteger(block) && block >= 0) return t('screens.my_blockchain_view.text_072', { value1: login, value2: block });
|
||||
if (Number.isInteger(block) && block >= 0) return t('screens.my_blockchain_view.text_073', { value1: block });
|
||||
return login || '';
|
||||
}
|
||||
|
||||
@@ -131,22 +132,22 @@ function channelNameText(lineCode, channelNames) {
|
||||
|
||||
function channelLabel(lineCode, channelNames) {
|
||||
const name = channelNameText(lineCode, channelNames);
|
||||
return name ? `канале ${name}` : 'канале';
|
||||
return name ? t('screens.my_blockchain_view.text_074', { value1: name }) : t('screens.my_blockchain_view.text_039');
|
||||
}
|
||||
|
||||
function lineTextKindLabel(subType) {
|
||||
if (subType === 100) return 'Входная страница';
|
||||
if (subType === 110) return 'Упражнение';
|
||||
if (subType === 120) return 'Услуга';
|
||||
if (subType === 130) return 'Курс';
|
||||
return 'Сообщение';
|
||||
if (subType === 100) return t('screens.my_blockchain_view.text_040');
|
||||
if (subType === 110) return t('screens.my_blockchain_view.text_041');
|
||||
if (subType === 120) return t('screens.my_blockchain_view.text_042');
|
||||
if (subType === 130) return t('screens.my_blockchain_view.text_043');
|
||||
return t('screens.my_blockchain_view.text_044');
|
||||
}
|
||||
|
||||
function describeEntry(item, inspection, channelNames) {
|
||||
if (!inspection?.frame) {
|
||||
return {
|
||||
title: `Событие ${item.msgType}/${item.msgSubType}`,
|
||||
detailTitle: `Событие ${item.msgType}/${item.msgSubType}`,
|
||||
title: t('screens.my_blockchain_view.text_075', { value1: item.msgType, value2: item.msgSubType }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_076', { value1: item.msgType, value2: item.msgSubType }),
|
||||
text: '',
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
@@ -157,22 +158,22 @@ function describeEntry(item, inspection, channelNames) {
|
||||
const subType = Number(frame.subType);
|
||||
|
||||
if (type === 0 && subType === 0) {
|
||||
return { title: 'Начало блокчейна', detailTitle: 'Начало блокчейна', text: body.login ? `Владелец: ${body.login}` : '', attachmentsCount: 0 };
|
||||
return { title: t('screens.my_blockchain_view.text_002'), detailTitle: t('screens.my_blockchain_view.text_045'), text: body.login ? t('screens.my_blockchain_view.text_077', { value1: body.login }) : '', attachmentsCount: 0 };
|
||||
}
|
||||
if (type === 0 && subType === 1) {
|
||||
const displayName = String(body.channelMeta?.title || body.channelName || '').trim() || `#${frame.blockNumber}`;
|
||||
return {
|
||||
title: `Создан канал «${displayName}»`,
|
||||
detailTitle: 'Создание канала',
|
||||
title: t('screens.my_blockchain_view.text_078', { value1: displayName }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_046'),
|
||||
text: String(body.channelMeta?.description || '').trim(),
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
}
|
||||
if (type === 0 && subType === 2) {
|
||||
const reason = FORK_REASON_LABELS.get(Number(body.reasonCode)) || `Причина ${body.reasonCode ?? '—'}`;
|
||||
const reason = FORK_REASON_LABELS().get(Number(body.reasonCode)) || t('screens.my_blockchain_view.text_079', { value1: body.reasonCode ?? '—' });
|
||||
return {
|
||||
title: `Создан новый fork · ${reason}`,
|
||||
detailTitle: 'Смена ключей / fork',
|
||||
title: t('screens.my_blockchain_view.text_080', { value1: reason }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_047'),
|
||||
text: String(body.comment || '').trim(),
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
@@ -180,55 +181,55 @@ function describeEntry(item, inspection, channelNames) {
|
||||
|
||||
if (type === 1 && [10, 100, 110, 120, 130].includes(subType)) {
|
||||
const kind = lineTextKindLabel(subType);
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? `Вложений: ${body.attachmentsCount}` : 'Без текста');
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? t('screens.my_blockchain_view.text_081', { value1: body.attachmentsCount }) : t('screens.my_blockchain_view.text_048'));
|
||||
return {
|
||||
title: `${kind} в ${channelLabel(body.line?.lineCode, channelNames)}: ${preview}`,
|
||||
detailTitle: `${kind} в ${channelLabel(body.line?.lineCode, channelNames)}`,
|
||||
title: t('screens.my_blockchain_view.text_082', { value1: kind, value2: channelLabel(body.line?.lineCode, channelNames), value3: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_083', { value1: kind, value2: channelLabel(body.line?.lineCode, channelNames) }),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 11) {
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? `Вложений: ${body.attachmentsCount}` : 'Сообщение удалено');
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? t('screens.my_blockchain_view.text_084', { value1: body.attachmentsCount }) : t('screens.my_blockchain_view.text_049'));
|
||||
return {
|
||||
title: `Отредактировано сообщение: ${preview}`,
|
||||
detailTitle: 'Редактирование сообщения',
|
||||
title: t('screens.my_blockchain_view.text_085', { value1: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_050'),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 20) {
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? `Вложений: ${body.attachmentsCount}` : 'Без текста');
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? t('screens.my_blockchain_view.text_086', { value1: body.attachmentsCount }) : t('screens.my_blockchain_view.text_051'));
|
||||
return {
|
||||
title: `Ответ ${targetText(body.target)}: ${preview}`,
|
||||
detailTitle: `Ответ на ${targetText(body.target)}`,
|
||||
title: t('screens.my_blockchain_view.text_087', { value1: targetText(body.target), value2: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_088', { value1: targetText(body.target) }),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 21) {
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? `Вложений: ${body.attachmentsCount}` : 'Ответ удалён');
|
||||
const preview = previewText(body.text) || (body.attachmentsCount ? t('screens.my_blockchain_view.text_089', { value1: body.attachmentsCount }) : t('screens.my_blockchain_view.text_052'));
|
||||
return {
|
||||
title: `Отредактирован ответ: ${preview}`,
|
||||
detailTitle: 'Редактирование ответа',
|
||||
title: t('screens.my_blockchain_view.text_090', { value1: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_053'),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 30) {
|
||||
const preview = previewText(body.text) || 'Без текста';
|
||||
const preview = previewText(body.text) || t('screens.my_blockchain_view.text_067');
|
||||
return {
|
||||
title: `Добавлен отзыв ${targetText(body.target)}: ${preview}`,
|
||||
detailTitle: `Отзыв на ${targetText(body.target)}`,
|
||||
title: t('screens.my_blockchain_view.text_091', { value1: targetText(body.target), value2: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_092', { value1: targetText(body.target) }),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 50) {
|
||||
const preview = previewText(body.text) || 'Без комментария';
|
||||
const preview = previewText(body.text) || t('screens.my_blockchain_view.text_068');
|
||||
return {
|
||||
title: `Репост в ${channelLabel(body.line?.lineCode, channelNames)}: ${preview}`,
|
||||
detailTitle: `Репост ${targetText(body.target)}`,
|
||||
title: t('screens.my_blockchain_view.text_093', { value1: channelLabel(body.line?.lineCode, channelNames), value2: preview }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_094', { value1: targetText(body.target) }),
|
||||
text: String(body.text || ''),
|
||||
attachmentsCount: Number(body.attachmentsCount || 0),
|
||||
};
|
||||
@@ -237,49 +238,49 @@ function describeEntry(item, inspection, channelNames) {
|
||||
const channelName = channelNameText(body.line?.lineCode, channelNames);
|
||||
const title = String(body.channelMeta?.title || '').trim();
|
||||
const description = previewText(body.channelMeta?.description || '');
|
||||
const changed = [title ? `название «${title}»` : '', body.channelMeta?.avatarAr ? 'аватар' : '', description ? `описание: ${description}` : ''].filter(Boolean).join(' · ');
|
||||
const changed = [title ? t('screens.my_blockchain_view.text_095', { value1: title }) : '', body.channelMeta?.avatarAr ? t('screens.my_blockchain_view.text_054') : '', description ? t('screens.my_blockchain_view.text_096', { value1: description }) : ''].filter(Boolean).join(' · ');
|
||||
return {
|
||||
title: `Изменён профиль канала${channelName ? ` ${channelName}` : ''}${changed ? ` · ${changed}` : ''}`,
|
||||
detailTitle: `Профиль канала${channelName ? ` ${channelName}` : ''}`,
|
||||
title: t('screens.my_blockchain_view.text_097', { value1: channelName ? ` ${channelName}` : '', value2: changed ? ` · ${changed}` : '' }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_098', { value1: channelName ? ` ${channelName}` : '' }),
|
||||
text: String(body.channelMeta?.description || ''),
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
}
|
||||
if (type === 1 && subType === 92) {
|
||||
return {
|
||||
title: `Удалён канал${channelNameText(body.line?.lineCode, channelNames) ? ` ${channelNameText(body.line?.lineCode, channelNames)}` : ''}`,
|
||||
detailTitle: 'Удаление канала',
|
||||
title: t('screens.my_blockchain_view.text_099', { value1: channelNameText(body.line?.lineCode, channelNames) ? ` ${channelNameText(body.line?.lineCode, channelNames)}` : '' }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_055'),
|
||||
text: '',
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 2 && (subType === 1 || subType === 2)) {
|
||||
const action = subType === 1 ? 'Поставлен лайк' : 'Лайк снят';
|
||||
const action = subType === 1 ? t('screens.my_blockchain_view.text_056') : t('screens.my_blockchain_view.text_057');
|
||||
return { title: `${action} · ${targetText(body.target)}`, detailTitle: action, text: '', attachmentsCount: 0 };
|
||||
}
|
||||
|
||||
if (type === 3) {
|
||||
const connection = CONNECTION_LABELS.get(subType);
|
||||
const action = connection?.[0] || `Изменена связь (${subType})`;
|
||||
const connection = CONNECTION_LABELS().get(subType);
|
||||
const action = connection?.[0] || t('screens.my_blockchain_view.text_100', { value1: subType });
|
||||
const target = targetText(body.target);
|
||||
return { title: `${action}${target ? ` · ${target}` : ''}`, detailTitle: connection?.[1] || 'Связь', text: '', attachmentsCount: 0 };
|
||||
return { title: `${action}${target ? ` · ${target}` : ''}`, detailTitle: connection?.[1] || t('screens.my_blockchain_view.text_069'), text: '', attachmentsCount: 0 };
|
||||
}
|
||||
|
||||
if (type === 4 && subType === 1) {
|
||||
const key = String(body.key || '').trim();
|
||||
const label = PROFILE_LABELS.get(key) || key || 'Параметр';
|
||||
const label = PROFILE_LABELS().get(key) || key || t('screens.my_blockchain_view.text_070');
|
||||
const value = profileValueLabel(key, body.value);
|
||||
return {
|
||||
title: key === 'ava' ? 'Профиль · Изменена аватарка' : `Профиль · ${label}: ${previewText(value) || '—'}`,
|
||||
detailTitle: `Изменение профиля · ${label}`,
|
||||
title: key === 'ava' ? t('screens.my_blockchain_view.text_058') : t('screens.my_blockchain_view.text_101', { value1: label, value2: previewText(value) || '—' }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_102', { value1: label }),
|
||||
text: key === 'ava' ? '' : String(value || ''),
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 5) {
|
||||
const action = STATUS_LABELS.get(subType) || `Статус ${subType}`;
|
||||
const action = STATUS_LABELS().get(subType) || t('screens.my_blockchain_view.text_103', { value1: subType });
|
||||
const preview = previewText(body.text);
|
||||
return {
|
||||
title: `${action} · ${targetText(body.target)}${preview ? `: ${preview}` : ''}`,
|
||||
@@ -290,8 +291,8 @@ function describeEntry(item, inspection, channelNames) {
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Событие ${type}/${subType}`,
|
||||
detailTitle: `Событие ${type}/${subType}`,
|
||||
title: t('screens.my_blockchain_view.text_104', { value1: type, value2: subType }),
|
||||
detailTitle: t('screens.my_blockchain_view.text_105', { value1: type, value2: subType }),
|
||||
text: '',
|
||||
attachmentsCount: 0,
|
||||
};
|
||||
@@ -311,25 +312,25 @@ function buildInternalAction({ inspection, blockchainName, login }) {
|
||||
const subType = Number(frame?.subType);
|
||||
if (type === 0 && subType === 1 && body.channelName) {
|
||||
const route = makeShineChannelRoute({ ownerBlockchainName: blockchainName, channelName: body.channelName });
|
||||
return route ? { label: 'Открыть канал →', route } : null;
|
||||
return route ? { label: t('screens.my_blockchain_view.text_003'), route } : null;
|
||||
}
|
||||
if (type === 1 && [10, 20, 50, 100, 110, 120, 130].includes(subType)) {
|
||||
const route = makeShineMessageRoute({ messageBlockchainName: blockchainName, messageBlockNumber: frame.blockNumber });
|
||||
return route ? { label: subType === 20 ? 'Открыть ответ →' : 'Открыть сообщение →', route } : null;
|
||||
return route ? { label: subType === 20 ? t('screens.my_blockchain_view.text_059') : t('screens.my_blockchain_view.text_060'), route } : null;
|
||||
}
|
||||
if (type === 1 && [11, 21].includes(subType) && Number.isInteger(Number(body.target?.toBlockNumber))) {
|
||||
const route = makeShineMessageRoute({ messageBlockchainName: blockchainName, messageBlockNumber: Number(body.target.toBlockNumber) });
|
||||
return route ? { label: subType === 11 ? 'Открыть исходное сообщение →' : 'Открыть исходный ответ →', route } : null;
|
||||
return route ? { label: subType === 11 ? t('screens.my_blockchain_view.text_061') : t('screens.my_blockchain_view.text_062'), route } : null;
|
||||
}
|
||||
if ((type === 1 && subType === 30) || type === 2 || type === 5) {
|
||||
const targetBch = targetBlockchainName(body.target);
|
||||
if (!targetBch) return null;
|
||||
const route = makeShineMessageRoute({ messageBlockchainName: targetBch, messageBlockNumber: body.target.toBlockNumber });
|
||||
return route ? { label: 'Открыть цель →', route } : null;
|
||||
return route ? { label: t('screens.my_blockchain_view.text_004'), route } : null;
|
||||
}
|
||||
if (type === 4) {
|
||||
const route = makeProfileRoute(login);
|
||||
return route ? { label: 'Открыть профиль →', route } : null;
|
||||
return route ? { label: t('screens.my_blockchain_view.text_005'), route } : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -352,10 +353,10 @@ function addDetailRow(container, label, value, { code = false } = {}) {
|
||||
function addTargetRows(container, target, fallbackLogin = '') {
|
||||
if (!target) return;
|
||||
const login = String(target.toLogin || fallbackLogin || '').trim();
|
||||
if (login) addDetailRow(container, 'Цель', login);
|
||||
if (Number.isInteger(Number(target.toForkNumber))) addDetailRow(container, 'Fork цели', target.toForkNumber);
|
||||
if (Number.isInteger(Number(target.toBlockNumber))) addDetailRow(container, 'Блок цели', `#${target.toBlockNumber}`);
|
||||
if (target.toBlockHash) addDetailRow(container, 'Хэш цели', target.toBlockHash, { code: true });
|
||||
if (login) addDetailRow(container, t('screens.my_blockchain_view.text_012'), login);
|
||||
if (Number.isInteger(Number(target.toForkNumber))) addDetailRow(container, t('screens.my_blockchain_view.text_013'), target.toForkNumber);
|
||||
if (Number.isInteger(Number(target.toBlockNumber))) addDetailRow(container, t('screens.my_blockchain_view.text_014'), `#${target.toBlockNumber}`);
|
||||
if (target.toBlockHash) addDetailRow(container, t('screens.my_blockchain_view.text_015'), target.toBlockHash, { code: true });
|
||||
}
|
||||
|
||||
function createEntryCard({ item, inspection, parseError, channelNames, blockchainName, login, navigate }) {
|
||||
@@ -381,7 +382,7 @@ function createEntryCard({ item, inspection, parseError, channelNames, blockchai
|
||||
toggle.type = 'button';
|
||||
toggle.className = 'ui-button my-blockchain-entry__toggle';
|
||||
toggle.setAttribute('aria-expanded', 'false');
|
||||
toggle.setAttribute('aria-label', `Подробнее о блоке #${item.blockNumber}`);
|
||||
toggle.setAttribute('aria-label', t('screens.my_blockchain_view.text_106', { value1: item.blockNumber }));
|
||||
const triangle = document.createElement('span');
|
||||
triangle.className = 'my-blockchain-entry__triangle';
|
||||
triangle.setAttribute('aria-hidden', 'true');
|
||||
@@ -406,7 +407,7 @@ function createEntryCard({ item, inspection, parseError, channelNames, blockchai
|
||||
if (description.attachmentsCount > 0) {
|
||||
const attachments = document.createElement('div');
|
||||
attachments.className = 'my-blockchain-entry__attachments meta-muted';
|
||||
attachments.textContent = description.attachmentsCount === 1 ? 'Вложение: 1' : `Вложения: ${description.attachmentsCount}`;
|
||||
attachments.textContent = description.attachmentsCount === 1 ? t('screens.my_blockchain_view.text_063') : t('screens.my_blockchain_view.text_107', { value1: description.attachmentsCount });
|
||||
details.append(attachments);
|
||||
}
|
||||
|
||||
@@ -427,7 +428,7 @@ function createEntryCard({ item, inspection, parseError, channelNames, blockchai
|
||||
arweave.href = inspection.arweaveUrl;
|
||||
arweave.target = '_blank';
|
||||
arweave.rel = 'noopener noreferrer';
|
||||
arweave.textContent = 'Открыть запись в блокчейне ↗';
|
||||
arweave.textContent = t('screens.my_blockchain_view.text_006');
|
||||
actions.append(arweave);
|
||||
}
|
||||
if (actions.childElementCount) details.append(actions);
|
||||
@@ -435,29 +436,29 @@ function createEntryCard({ item, inspection, parseError, channelNames, blockchai
|
||||
const info = document.createElement('div');
|
||||
info.className = 'my-blockchain-entry__detail-grid';
|
||||
const effectiveType = frame ? `${frame.type}/${frame.subType} · v${frame.version}` : `${item.msgType}/${item.msgSubType} · v${item.msgVersion}`;
|
||||
addDetailRow(info, 'Тип', effectiveType);
|
||||
addDetailRow(info, 'Блок', `#${item.blockNumber}`);
|
||||
addDetailRow(info, 'Дата', formatDate(item.timestampMs));
|
||||
addDetailRow(info, 'Хэш блока', item.blockHash, { code: true });
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_016'), effectiveType);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_017'), `#${item.blockNumber}`);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_018'), formatDate(item.timestampMs));
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_019'), item.blockHash, { code: true });
|
||||
if (inspection?.dataItemId) addDetailRow(info, 'DataItem ID', inspection.dataItemId, { code: true });
|
||||
|
||||
const body = frame?.body || {};
|
||||
if (body.line) {
|
||||
if (Number.isInteger(Number(body.line.lineCode))) addDetailRow(info, 'Линия', `#${body.line.lineCode}`);
|
||||
if (Number.isInteger(Number(body.line.lineSequence))) addDetailRow(info, 'Шаг линии', body.line.lineSequence);
|
||||
if (Number.isInteger(Number(body.line.lineCode))) addDetailRow(info, t('screens.my_blockchain_view.text_020'), `#${body.line.lineCode}`);
|
||||
if (Number.isInteger(Number(body.line.lineSequence))) addDetailRow(info, t('screens.my_blockchain_view.text_021'), body.line.lineSequence);
|
||||
}
|
||||
if (body.kind === 'profile') {
|
||||
addDetailRow(info, 'Параметр', body.key);
|
||||
addDetailRow(info, 'Значение', body.value, { code: body.key === 'ava' });
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_022'), body.key);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_023'), body.value, { code: body.key === 'ava' });
|
||||
}
|
||||
if (body.kind === 'create_channel') {
|
||||
addDetailRow(info, 'Техническое имя', body.channelName);
|
||||
addDetailRow(info, 'Тип канала', `${body.channelType} · v${body.channelTypeVersion}`);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_024'), body.channelName);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_025'), `${body.channelType} · v${body.channelTypeVersion}`);
|
||||
}
|
||||
if (body.kind === 'fork') {
|
||||
addDetailRow(info, 'Fork point', `#${body.forkPointBlockNumber}`);
|
||||
addDetailRow(info, 'Старый tip', `#${body.parentTipBlockNumber}`);
|
||||
addDetailRow(info, 'Отброшено блоков', body.discardedBlocksCount);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_026'), `#${body.parentTipBlockNumber}`);
|
||||
addDetailRow(info, t('screens.my_blockchain_view.text_027'), body.discardedBlocksCount);
|
||||
}
|
||||
if (body.target) addTargetRows(info, body.target, (frame?.type === 1 && [11, 21].includes(Number(frame?.subType))) ? login : '');
|
||||
if (!body.target && item.toLogin) {
|
||||
@@ -468,7 +469,7 @@ function createEntryCard({ item, inspection, parseError, channelNames, blockchai
|
||||
toBlockHash: item.toBlockHash,
|
||||
});
|
||||
}
|
||||
if (parseError) addDetailRow(info, 'Разбор блока', parseError);
|
||||
if (parseError) addDetailRow(info, t('screens.my_blockchain_view.text_028'), parseError);
|
||||
details.append(info);
|
||||
|
||||
toggle.addEventListener('click', () => {
|
||||
@@ -486,7 +487,7 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
const screen = document.createElement('section');
|
||||
screen.className = 'stack my-blockchain-screen';
|
||||
chrome?.setTopbar(createTopBar({
|
||||
title: historyOnly ? 'История моего блокчейна' : 'Мой блокчейн',
|
||||
title: historyOnly ? t('screens.my_blockchain_view.text_064') : t('screens.my_blockchain_view.text_065'),
|
||||
back: { label: '←', onClick: () => navigate(historyOnly ? 'my-blockchain-view' : 'settings-view') },
|
||||
}));
|
||||
|
||||
@@ -496,17 +497,17 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
const historyButton = document.createElement('button');
|
||||
historyButton.type = 'button';
|
||||
historyButton.className = 'nav-row';
|
||||
historyButton.textContent = 'Показать историю моего блокчейна';
|
||||
historyButton.textContent = t('screens.my_blockchain_view.text_007');
|
||||
historyButton.addEventListener('click', () => navigate('my-blockchain-history-view'));
|
||||
const filesButton = document.createElement('button');
|
||||
filesButton.type = 'button';
|
||||
filesButton.className = 'nav-row';
|
||||
filesButton.textContent = 'Файлы в блокчейне';
|
||||
filesButton.textContent = t('screens.my_blockchain_view.text_008');
|
||||
filesButton.addEventListener('click', () => navigate('arweave-uploads-view'));
|
||||
const remoteButton = document.createElement('button');
|
||||
remoteButton.type = 'button';
|
||||
remoteButton.className = 'nav-row';
|
||||
remoteButton.textContent = 'Использовать ключ блокчейна с внешнего устройства';
|
||||
remoteButton.textContent = t('screens.my_blockchain_view.text_009');
|
||||
remoteButton.addEventListener('click', () => navigate('remote-addblock-session-view'));
|
||||
intro.append(historyButton, filesButton, remoteButton);
|
||||
screen.append(intro);
|
||||
@@ -520,7 +521,7 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
const more = document.createElement('button');
|
||||
more.type = 'button';
|
||||
more.className = 'secondary-btn';
|
||||
more.textContent = 'Показать более ранние записи';
|
||||
more.textContent = t('screens.my_blockchain_view.text_010');
|
||||
more.hidden = true;
|
||||
screen.append(more);
|
||||
|
||||
@@ -572,7 +573,7 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
}
|
||||
|
||||
const rows = await Promise.all((data.blocks || []).map(async (item) => {
|
||||
if (!item?.blockBytesB64) return { item, inspection: null, parseError: 'Сервер не вернул сырые bytes блока.' };
|
||||
if (!item?.blockBytesB64) return { item, inspection: null, parseError: t('screens.my_blockchain_view.text_066') };
|
||||
try {
|
||||
const inspection = await inspectBlockchainDataItem(item.blockBytesB64);
|
||||
const body = inspection?.frame?.body;
|
||||
@@ -583,7 +584,7 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
}
|
||||
return { item, inspection, parseError: '' };
|
||||
} catch (error) {
|
||||
return { item, inspection: null, parseError: String(error?.message || error || 'Неизвестная ошибка разбора') };
|
||||
return { item, inspection: null, parseError: String(error?.message || error || t('screens.my_blockchain_view.text_071')) };
|
||||
}
|
||||
}));
|
||||
if (disposed || seq !== loadSeq) return;
|
||||
@@ -603,14 +604,14 @@ export function render({ navigate, chrome }, { historyOnly = false } = {}) {
|
||||
if (!(data.blocks || []).length && reset) {
|
||||
const empty = document.createElement('div');
|
||||
empty.className = 'card';
|
||||
empty.textContent = 'Записей пока нет.';
|
||||
empty.textContent = t('screens.my_blockchain_view.text_011');
|
||||
list.append(empty);
|
||||
}
|
||||
} catch (error) {
|
||||
if (disposed || seq !== loadSeq) return;
|
||||
const err = document.createElement('div');
|
||||
err.className = 'card';
|
||||
err.textContent = actionErrorText('Не удалось загрузить блокчейн', error);
|
||||
err.textContent = actionErrorText(t('screens.my_blockchain_view.text_029'), error);
|
||||
list.append(err);
|
||||
} finally {
|
||||
if (seq === loadSeq) {
|
||||
|
||||
Reference in New Issue
Block a user