SHA256
HEADER v3, primary аккаунты и подтверждения
This commit is contained in:
@@ -6,6 +6,7 @@ import { appendShineMessageLinks } from '../services/shine-message-links.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { openBlockchainDetailsModal } from '../components/blockchain-details-dialog.js';
|
||||
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
|
||||
import { publicLikeCount, hasLikeStatistics } from '../services/public-like-count.js';
|
||||
import { iconHtml } from '../components/ui-icon.js';
|
||||
import { consumeReplyEditorOnOpen, rememberChannelPosition, readChannelPosition, restoreChannelPosition } from '../services/channel-view-state.js';
|
||||
import { attachMessageMenu } from '../components/message-menu.js';
|
||||
@@ -624,9 +625,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
const versions = Array.isArray(node?.versions) ? node.versions : [];
|
||||
const versionsTotal = Number(node?.versionsTotal || versions.length || 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);
|
||||
const likes = publicLikeCount(node);
|
||||
const replies = replyCountOf(node);
|
||||
const ratings = Number(node?.ratingsCount || 0);
|
||||
const isOwnMessage = Boolean(state.session.isAuthorized && state.session.login) && String(node?.authorLogin || '').trim().toLowerCase() === String(state.session.login).trim().toLowerCase();
|
||||
@@ -836,7 +835,7 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
const likesStatsButton = document.createElement('button');
|
||||
likesStatsButton.type = 'button';
|
||||
likesStatsButton.className = 'ui-button channel-action-item channel-action-like-stats';
|
||||
likesStatsButton.textContent = String(Number(likes) || '');
|
||||
likesStatsButton.textContent = String(likes);
|
||||
likesStatsButton.setAttribute('aria-label', t('screens.channel_thread_view.text_103', { value1: likes }));
|
||||
likesStatsButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
@@ -920,8 +919,8 @@ function renderNodeCard(node, heading, handlers, localNumber, { focusPost = fals
|
||||
if (!REPOSTS_ENABLED) { notifyRepostSoon(); return; }
|
||||
void handlers.onRepost?.(target);
|
||||
});
|
||||
if (threadsLayout) actions.append(likeButton, ...(likes > 0 ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(likes > 0 ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
if (threadsLayout) actions.append(likeButton, ...(hasLikeStatistics(node) ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(hasLikeStatistics(node) ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
const supportBtn = document.createElement('button');
|
||||
supportBtn.type = 'button';
|
||||
supportBtn.className = 'ui-button channel-action-item channel-action-support';
|
||||
@@ -1169,7 +1168,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
|
||||
setMessageReactionState(target, node?.likedByMe === true ? 'liked' : 'unliked');
|
||||
const liked = getMessageReactionState(target) === 'liked';
|
||||
const likes = Number(node?.likesCount || 0);
|
||||
const likes = publicLikeCount(node);
|
||||
const like = document.createElement('button');
|
||||
like.type = 'button';
|
||||
like.className = `channel-action-item thread-comment__like${liked ? ' is-liked' : ''}`;
|
||||
@@ -1186,7 +1185,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
const commentLikeStats = document.createElement('button');
|
||||
commentLikeStats.type = 'button';
|
||||
commentLikeStats.className = 'channel-action-item thread-comment__like-count';
|
||||
commentLikeStats.textContent = String(likes || '');
|
||||
commentLikeStats.textContent = String(likes);
|
||||
commentLikeStats.setAttribute('aria-label', t('screens.channel_thread_view.text_107', { value1: likes }));
|
||||
commentLikeStats.addEventListener('click', () => { void showLikeStatistics({ counts: node }); });
|
||||
|
||||
@@ -1247,7 +1246,7 @@ function renderComment({ node, parent, focus, channelOwner, handlers, nested = f
|
||||
repost.addEventListener('click', () => (REPOSTS_ENABLED ? handlers.onRepost?.(target) : notifyRepostSoon()));
|
||||
|
||||
// Ряд действий как у записи канала: лайк, ответы, репост, поделиться.
|
||||
actions.append(like, ...(likes > 0 ? [commentLikeStats] : []), reply, repost, share);
|
||||
actions.append(like, ...(hasLikeStatistics(node) ? [commentLikeStats] : []), reply, repost, share);
|
||||
const supportBtn = document.createElement('button');
|
||||
supportBtn.type = 'button';
|
||||
supportBtn.className = 'channel-action-item thread-comment__support';
|
||||
|
||||
@@ -7,6 +7,7 @@ import { appendShineMessageLinks } from '../services/shine-message-links.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { openBlockchainDetailsModal } from '../components/blockchain-details-dialog.js';
|
||||
import { confirmLikeAction, showLikeStatistics } from '../components/like-action-sheet.js';
|
||||
import { publicLikeCount, hasLikeStatistics } from '../services/public-like-count.js';
|
||||
import { iconHtml } from '../components/ui-icon.js';
|
||||
import { createOverflowDots } from '../components/overflow-dots.js';
|
||||
import { rememberChannelPosition, readChannelPosition, requestReplyEditorOnOpen, restoreChannelPosition } from '../services/channel-view-state.js';
|
||||
@@ -1990,7 +1991,7 @@ function renderPostCard(post, {
|
||||
<span class="channel-action-label">${isPending ? t('screens.channel_view.text_096') : t('screens.channel_view.text_097')}</span>
|
||||
`;
|
||||
likeButton.setAttribute('aria-pressed', String(isLiked));
|
||||
setActionTitle(likeButton, isPending ? t('screens.channel_view.text_098') : `${isLiked ? t('screens.channel_view.text_099') : t('screens.channel_view.text_100')}, ${post.likesCount || 0}`);
|
||||
setActionTitle(likeButton, isPending ? t('screens.channel_view.text_098') : `${isLiked ? t('screens.channel_view.text_099') : t('screens.channel_view.text_100')}, ${publicLikeCount(post)}`);
|
||||
likeButton.disabled = isPending;
|
||||
likeButton.addEventListener('click', async (event) => {
|
||||
event.stopPropagation();
|
||||
@@ -2009,8 +2010,8 @@ function renderPostCard(post, {
|
||||
const likesStatsButton = document.createElement('button');
|
||||
likesStatsButton.type = 'button';
|
||||
likesStatsButton.className = 'ui-button channel-action-item channel-action-like-stats';
|
||||
likesStatsButton.textContent = String(Number(post.likesCount) || '');
|
||||
likesStatsButton.setAttribute('aria-label', t('screens.channel_view.text_150', { value1: Number(post.likesCount) || 0 }));
|
||||
likesStatsButton.textContent = String(publicLikeCount(post));
|
||||
likesStatsButton.setAttribute('aria-label', t('screens.channel_view.text_150', { value1: publicLikeCount(post) }));
|
||||
likesStatsButton.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
void showLikeStatistics({
|
||||
@@ -2158,8 +2159,8 @@ function renderPostCard(post, {
|
||||
} });
|
||||
});
|
||||
// Четыре кнопки как в Threads: лайк, ответы, репост, поделиться.
|
||||
if (threadsLayout) actions.append(likeButton, ...(Number(post.likesCount) > 0 ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(Number(post.likesCount) > 0 ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
if (threadsLayout) actions.append(likeButton, ...(hasLikeStatistics(post) ? [likesStatsButton] : []), discussionButton, repostButton, shareButton);
|
||||
else actions.append(likeButton, ...(hasLikeStatistics(post) ? [likesStatsButton] : []), shareButton, discussionButton);
|
||||
actions.append(supportButton);
|
||||
if (selector?.publicOrdinalUrlsAllowed && post.messageRef?.blockNumber != null) {
|
||||
const streamRoute = makeShineChannelStreamRoute({
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
PROFILE_GENDER_MALE,
|
||||
PROFILE_GENDER_UNKNOWN,
|
||||
PROFILE_ACCOUNT_ROLE_PRIMARY,
|
||||
PROFILE_ACCOUNT_ROLE_NON_VOTING,
|
||||
PROFILE_SHINE_SHINING,
|
||||
PROFILE_SHINE_UNKNOWN,
|
||||
loadProfileSnapshot,
|
||||
@@ -36,18 +35,6 @@ function shineStatusLabel(value) {
|
||||
|
||||
|
||||
|
||||
function officialSteps(firstName, lastName) {
|
||||
const name = `${firstName} ${lastName}`.trim();
|
||||
return [
|
||||
{ title: t('dialogs.final.consent.official_steps.odin_chelovek_odin_ofitsialnyy_akkaunt'), text: t('dialogs.final.consent.official_steps.ofitsialnyy_akkaunt_vashe_zayavlenie_chto_eto_vash') },
|
||||
{ title: t('dialogs.final.consent.official_steps.priznanie_zavisit_ot_drugih_lyudey'), text: t('dialogs.final.consent.official_steps.samo_zayavlenie_ne_delaet_lichnost_proverennoy_dru') },
|
||||
{ title: t('dialogs.final.consent.official_steps.istoriya_perezhivaet_akkaunt'), text: t('dialogs.final.consent.official_steps.esli_vy_poteryaete_dostup_mozhno_zaregistrirovat_n') },
|
||||
{ title: t('dialogs.final.consent.official_steps.eto_deystvitelno_vy'), text: t('dialogs.final.consent.official_steps.v_profile_ukazano_value1_podtverzhdayte_tolko_esli', { value1: name }), accept: t('dialogs.final.consent.official_steps.podtverzhdayu_chto_value1_moi_nastoyaschie_imya_i', { value1: name }) },
|
||||
{ title: t('dialogs.final.consent.official_steps.podtverzhdaya_drugih_otvechayte_za_svoi_slova'), text: t('dialogs.final.consent.official_steps.ofitsialnyy_akkaunt_mozhet_podtverzhdat_osnovnye_a'), accept: t('dialogs.final.consent.official_steps.ponimayu_otvetstvennost_za_svoi_podtverzhdeniya') },
|
||||
{ title: t('dialogs.final.consent.official_steps.publichnaya_zapis'), text: t('dialogs.final.consent.official_steps.zayavlenie_i_buduschie_podtverzhdeniya_popadayut_v'), accept: t('dialogs.final.consent.official_steps.ya_ponimayu_publichnost_i_dolgovremennoe_hranenie'), button: t('dialogs.final.consent.official_steps.stat_ofitsialnym') },
|
||||
];
|
||||
}
|
||||
|
||||
function shiningSteps() { return [
|
||||
{ title: t('dialogs.final.consent.shining_steps.siyayuschiy_ofitsialnyy'), text: t('dialogs.final.consent.shining_steps.otmetit_sebya_siyayuschim_mozhno_i_s_neofitsialnog') },
|
||||
{ title: t('dialogs.final.consent.shining_steps.chto_znachit_siyayuschiy'), text: t('dialogs.final.consent.shining_steps.v_shine_eto_chelovek_kotoryy_zanimaetsya_vnutrenni') },
|
||||
@@ -120,7 +107,7 @@ export function render({ navigate, chrome }) {
|
||||
const badgesRow = document.createElement('div');
|
||||
badgesRow.className = 'chip-row profile-edit-statuses';
|
||||
badgesRow.innerHTML = `
|
||||
<button class="chip profile-toggle-btn is-no" type="button" data-status="account_role">${th('screens.profile_edit_view.text_029')}</button>
|
||||
<span class="badge is-no" data-status="account_role">${th('screens.profile_edit_view.text_029')}</span>
|
||||
<button class="chip profile-toggle-btn is-no" type="button" data-status="shine">${th('screens.profile_edit_view.text_030')}</button>
|
||||
`;
|
||||
|
||||
@@ -138,6 +125,7 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
let currentFields = [];
|
||||
let currentAccountRole = '';
|
||||
let currentAccountType = null;
|
||||
let currentShineStatus = '';
|
||||
let currentGender = PROFILE_GENDER_UNKNOWN;
|
||||
let statusFlowOpen = false;
|
||||
@@ -229,7 +217,9 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
function updateStatusesUi() {
|
||||
if (accountRoleBtn) {
|
||||
accountRoleBtn.textContent = t('screens.profile_edit_view.text_020', { value1: accountRoleLabel(currentAccountRole) });
|
||||
accountRoleBtn.textContent = currentAccountType === 1 ? t('screens.profile_edit_view.text_009')
|
||||
: currentAccountType === 0 ? t('screens.registration_identity.alternative')
|
||||
: t('screens.profile_edit_view.text_020', { value1: accountRoleLabel(currentAccountRole) });
|
||||
accountRoleBtn.classList.remove('is-no', 'is-yes-official', 'is-yes-shine', 'is-not-interested');
|
||||
accountRoleBtn.classList.add(currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY ? 'is-yes-official' : 'is-no');
|
||||
}
|
||||
@@ -341,13 +331,13 @@ export function render({ navigate, chrome }) {
|
||||
status.className = 'status-line';
|
||||
status.textContent = t('dialogs.modals.profile_edit_view.label_003');
|
||||
reloadBtn.disabled = true;
|
||||
accountRoleBtn.disabled = true;
|
||||
shineBtn.disabled = true;
|
||||
|
||||
try {
|
||||
const snapshot = await loadProfileSnapshot(login);
|
||||
currentFields = snapshot.fields;
|
||||
currentAccountRole = snapshot.accountRole || '';
|
||||
currentAccountType = snapshot.accountType;
|
||||
currentShineStatus = snapshot.shineStatus || '';
|
||||
currentGender = snapshot.gender || PROFILE_GENDER_UNKNOWN;
|
||||
currentAvatar = snapshot.avatar || { value: '', source: '', txId: '', pr: '', timeMs: 0 };
|
||||
@@ -366,7 +356,6 @@ export function render({ navigate, chrome }) {
|
||||
showLocalErrorAlert(t('screens.profile_edit_view.text_007'), error);
|
||||
} finally {
|
||||
reloadBtn.disabled = false;
|
||||
accountRoleBtn.disabled = false;
|
||||
shineBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
@@ -409,63 +398,28 @@ export function render({ navigate, chrome }) {
|
||||
}
|
||||
|
||||
async function onStatusClick(statusKey) {
|
||||
if (statusFlowOpen) return;
|
||||
if (statusKey !== 'shine' || statusFlowOpen) return;
|
||||
statusFlowOpen = true;
|
||||
try {
|
||||
const isAccountRole = statusKey === 'account_role';
|
||||
const alreadyOn = isAccountRole
|
||||
? currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY
|
||||
: currentShineStatus === PROFILE_SHINE_SHINING;
|
||||
let accepted = false;
|
||||
if (alreadyOn) {
|
||||
accepted = await confirmDialog({
|
||||
title: isAccountRole ? t('dialogs.final.consent.remove_official') : t('dialogs.final.consent.remove_shining'),
|
||||
text: t('dialogs.pages.profile_edit_view.text_001'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_002'),
|
||||
});
|
||||
} else if (isAccountRole) {
|
||||
const firstName = String(currentFields.find((field) => field.key === 'first_name')?.value || '').trim();
|
||||
const lastName = String(currentFields.find((field) => field.key === 'last_name')?.value || '').trim();
|
||||
if (!firstName || !lastName) {
|
||||
await confirmDialog({
|
||||
title: t('dialogs.pages.profile_edit_view.title_003'),
|
||||
text: t('dialogs.pages.profile_edit_view.text_004'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_005'),
|
||||
cancelLabel: t('dialogs.pages.profile_edit_view.cancelLabel_006'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
accepted = await confirmConsentSteps({ title: t('dialogs.final.consent.official_title'), steps: officialSteps(firstName, lastName) });
|
||||
} else {
|
||||
accepted = await confirmConsentSteps({ title: t('dialogs.final.consent.shining_title'), steps: shiningSteps() });
|
||||
}
|
||||
const alreadyOn = currentShineStatus === PROFILE_SHINE_SHINING;
|
||||
const accepted = alreadyOn ? await confirmDialog({
|
||||
title: t('dialogs.final.consent.remove_shining'), text: t('dialogs.pages.profile_edit_view.text_001'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_002'),
|
||||
}) : await confirmConsentSteps({ title: t('dialogs.final.consent.shining_title'), steps: shiningSteps() });
|
||||
if (!accepted || !screen.isConnected) return;
|
||||
const nextValue = isAccountRole
|
||||
? (alreadyOn ? PROFILE_ACCOUNT_ROLE_NON_VOTING : PROFILE_ACCOUNT_ROLE_PRIMARY)
|
||||
: (alreadyOn ? PROFILE_SHINE_UNKNOWN : PROFILE_SHINE_SHINING);
|
||||
status.className = 'status-line';
|
||||
status.textContent = t('dialogs.modals.profile_edit_view.label_009');
|
||||
accountRoleBtn.disabled = true;
|
||||
status.className = 'status-line'; status.textContent = t('dialogs.modals.profile_edit_view.label_009');
|
||||
shineBtn.disabled = true;
|
||||
try {
|
||||
await saveProfileStatus(login, statusKey, nextValue);
|
||||
if (!screen.isConnected) return;
|
||||
await refreshProfileSnapshot();
|
||||
await saveProfileStatus(login, 'shine', alreadyOn ? PROFILE_SHINE_UNKNOWN : PROFILE_SHINE_SHINING);
|
||||
if (screen.isConnected) await refreshProfileSnapshot();
|
||||
} catch (error) {
|
||||
if (!screen.isConnected) return;
|
||||
status.className = 'status-line is-unavailable';
|
||||
const what = isAccountRole ? t('screens.profile_edit_view.text_017') : t('screens.profile_edit_view.text_018');
|
||||
const what = t('screens.profile_edit_view.text_018');
|
||||
status.textContent = t('screens.profile_edit_view.text_022', { value1: what, value2: toUserMessage(error, t('dialogs.modals.profile_edit_view.label_010')) });
|
||||
showLocalErrorAlert(t('screens.profile_edit_view.text_023', { value1: what }), error);
|
||||
} finally {
|
||||
if (screen.isConnected) {
|
||||
accountRoleBtn.disabled = false;
|
||||
shineBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
statusFlowOpen = false;
|
||||
}
|
||||
} finally { if (screen.isConnected) shineBtn.disabled = false; }
|
||||
} finally { statusFlowOpen = false; }
|
||||
}
|
||||
|
||||
async function onEditFieldClick(fieldKey) {
|
||||
@@ -547,7 +501,7 @@ export function render({ navigate, chrome }) {
|
||||
});
|
||||
|
||||
reloadBtn.addEventListener('click', refreshProfileSnapshot);
|
||||
accountRoleBtn.addEventListener('click', () => onStatusClick('account_role'));
|
||||
accountRoleBtn.title = t('screens.registration_identity.immutable');
|
||||
shineBtn.addEventListener('click', () => onStatusClick('shine'));
|
||||
avatarActionEl?.addEventListener('click', () => { void onChangeAvatarClick(); });
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { createRegistrationStepper } from '../components/registration-stepper.js
|
||||
import { authService, clearAuthMessages, clearRegistrationDraft, state } from '../state.js';
|
||||
import { PASSWORD_MAX_LENGTH } from '../services/password-words.js';
|
||||
import { getRegistrationNamespaces, checkRegistrationLogin } from '../services/registration-v2-api.js';
|
||||
import { savePendingHeaderIdentity } from '../services/pending-header-identity.js';
|
||||
import { normalizeFullLogin } from '../services/shine-namespace-service.js';
|
||||
|
||||
export const pageMeta = { id: 'register-view', get title() { return t('screens.register_view.text_001'); }, showAppChrome: false };
|
||||
@@ -36,6 +37,10 @@ export function render({ navigate }) {
|
||||
return window.confirm(t('screens.register_view.text_039'));
|
||||
}
|
||||
function goBack() {
|
||||
if (Number(draft.uiStep) === 3) {
|
||||
showPassword();
|
||||
return;
|
||||
}
|
||||
if (Number(draft.uiStep) === 2) {
|
||||
draft.uiStep = 1;
|
||||
showLogin();
|
||||
@@ -220,7 +225,7 @@ export function render({ navigate }) {
|
||||
// Hide the password before navigation to prevent a visible flash.
|
||||
input.clearPasswordField();
|
||||
refreshPasswordCount();
|
||||
navigate(flowType === 'free' ? 'registration-email-view' : 'registration-payment-view');
|
||||
showAccountType();
|
||||
} catch (error) {
|
||||
if (screen.isConnected && thisRequest === requestId) status.textContent = error.message || t('screens.register_view.text_028');
|
||||
} finally {
|
||||
@@ -231,11 +236,93 @@ export function render({ navigate }) {
|
||||
body.append(heading, description, label, guidance, status, next);
|
||||
}
|
||||
|
||||
function showAccountType() {
|
||||
draft.uiStep = 3;
|
||||
body.replaceChildren(createRegistrationStepper(3));
|
||||
const tr = key => t(`screens.registration_identity.${key}`);
|
||||
const [heading, description] = title(tr('title'), tr('immutable'));
|
||||
const choices = document.createElement('div'); choices.className = 'stack';
|
||||
const option = (type, name, detail) => {
|
||||
const label = document.createElement('label'); label.className = 'stack signup-guidance';
|
||||
const radio = document.createElement('input'); radio.type = 'radio'; radio.name = 'registration-account-type';
|
||||
radio.checked = draft.accountType === type;
|
||||
const titleRow = document.createElement('strong'); titleRow.append(radio, ' ' + tr(name));
|
||||
const p = document.createElement('p'); p.textContent = tr(detail);
|
||||
label.append(titleRow, p); choices.append(label);
|
||||
radio.addEventListener('change', () => { draft.accountType = type; refresh(); });
|
||||
};
|
||||
option(1, 'primary', 'primary_detail');
|
||||
option(0, 'alternative', 'alternative_detail');
|
||||
const previous = document.createElement('div'); previous.className = 'stack';
|
||||
const explanation = document.createElement('p'); explanation.textContent = tr('previous_detail');
|
||||
const disclosure = document.createElement('p'); disclosure.className = 'signup-guidance'; disclosure.textContent = tr('disclosure');
|
||||
const list = document.createElement('div'); list.className = 'stack';
|
||||
const add = document.createElement('button'); add.type = 'button'; add.className = 'secondary-btn'; add.textContent = tr('add');
|
||||
const searchBox = document.createElement('div'); searchBox.className = 'stack'; searchBox.hidden = true;
|
||||
const input = document.createElement('input'); input.className = 'input'; input.placeholder = tr('search'); input.autocomplete = 'off';
|
||||
const search = document.createElement('button'); search.type = 'button'; search.className = 'secondary-btn'; search.textContent = tr('find');
|
||||
const results = document.createElement('div'); results.className = 'stack';
|
||||
const status = statusLine();
|
||||
searchBox.append(input, search, results);
|
||||
previous.append(explanation, list, add, searchBox, disclosure);
|
||||
const next = document.createElement('button'); next.type = 'button'; next.className = 'primary-btn signup-next'; next.textContent = tr('next');
|
||||
let queryRevision = 0;
|
||||
function refresh() {
|
||||
previous.hidden = draft.accountType !== 1;
|
||||
next.disabled = draft.accountType === null;
|
||||
list.replaceChildren();
|
||||
for (const login of draft.previousAccounts) {
|
||||
const row = document.createElement('div'); row.className = 'signup-full-login';
|
||||
const remove = document.createElement('button'); remove.type = 'button'; remove.className = 'secondary-btn'; remove.textContent = '×';
|
||||
remove.setAttribute('aria-label', `${tr('remove')} ${login}`);
|
||||
remove.addEventListener('click', () => { draft.previousAccounts = draft.previousAccounts.filter(v => v !== login); refresh(); });
|
||||
row.append(login, ' ', remove); list.append(row);
|
||||
}
|
||||
add.disabled = draft.previousAccounts.length >= 10;
|
||||
if (add.disabled || draft.accountType !== 1) { searchBox.hidden = true; results.replaceChildren(); queryRevision++; }
|
||||
}
|
||||
add.addEventListener('click', () => { searchBox.hidden = false; input.focus(); });
|
||||
input.addEventListener('input', () => { queryRevision++; results.replaceChildren(); });
|
||||
input.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); search.click(); } });
|
||||
search.addEventListener('click', async () => {
|
||||
const query = input.value.trim(); if (!query) return;
|
||||
const revision = ++queryRevision; results.replaceChildren(); status.textContent = '';
|
||||
try {
|
||||
const users = await authService.searchPeople(query, { limit: 20 });
|
||||
if (!screen.isConnected || draft.uiStep !== 3 || revision !== queryRevision || draft.accountType !== 1) return;
|
||||
const seen = new Set([draft.login, ...draft.previousAccounts].map(v => v.toLowerCase()));
|
||||
for (const user of users) {
|
||||
const login = String(user?.login || '');
|
||||
if (!login || seen.has(login.toLowerCase())) continue;
|
||||
seen.add(login.toLowerCase());
|
||||
const choose = document.createElement('button'); choose.type = 'button'; choose.className = 'secondary-btn';
|
||||
choose.textContent = login;
|
||||
choose.addEventListener('click', () => {
|
||||
if (draft.previousAccounts.length >= 10 || draft.accountType !== 1 || draft.previousAccounts.some(v => v.toLowerCase() === login.toLowerCase())) return;
|
||||
draft.previousAccounts.push(login); input.value = ''; searchBox.hidden = true; results.replaceChildren(); queryRevision++; refresh();
|
||||
});
|
||||
results.append(choose);
|
||||
}
|
||||
if (!results.childElementCount) status.textContent = tr('not_found');
|
||||
} catch (error) { if (screen.isConnected && revision === queryRevision) status.textContent = error.message || tr('search_error'); }
|
||||
});
|
||||
next.addEventListener('click', () => {
|
||||
if (![0, 1].includes(draft.accountType)) return;
|
||||
try {
|
||||
if (draft.accountType === 0) draft.previousAccounts = [];
|
||||
savePendingHeaderIdentity(draft.login, draft.preGeneratedKeyBundle?.blockchainPair?.publicKeyB64, draft);
|
||||
navigate(flowType === 'free' ? 'registration-email-view' : 'registration-payment-view');
|
||||
} catch (error) { status.textContent = error.message; }
|
||||
});
|
||||
body.append(heading, description, choices, previous, status, next); refresh();
|
||||
}
|
||||
|
||||
if (flowType !== 'free' && flowType !== 'paid') {
|
||||
queueMicrotask(() => navigate('registration-choice-view'));
|
||||
return screen;
|
||||
}
|
||||
if (Number(draft.uiStep) === 2 && draft.login) showPassword();
|
||||
if (Number(draft.uiStep) === 3 && draft.login && draft.preGeneratedKeyBundle) showAccountType();
|
||||
else if (Number(draft.uiStep) === 2 && draft.login) showPassword();
|
||||
else showLogin();
|
||||
|
||||
void getRegistrationNamespaces().then(data => {
|
||||
|
||||
@@ -12,6 +12,9 @@ export function render({ navigate }) {
|
||||
const form = document.createElement('div');
|
||||
form.className = 'card stack registration-form signup-wizard__body';
|
||||
const draft = state.registrationDraft;
|
||||
if (![0, 1].includes(draft.accountType) || !draft.preGeneratedKeyBundle) {
|
||||
queueMicrotask(() => navigate('register-view')); return screen;
|
||||
}
|
||||
|
||||
const title = document.createElement('h1');
|
||||
title.className = 'signup-title';
|
||||
@@ -75,7 +78,7 @@ export function render({ navigate }) {
|
||||
edit.className = 'ghost-btn';
|
||||
edit.textContent = t('screens.registration_email_view.text_011');
|
||||
|
||||
form.append(createRegistrationStepper(3), title, lead, inputLabel, info, status, next, codeLabel, codeInfo, confirm, resend, edit);
|
||||
form.append(createRegistrationStepper(4), title, lead, inputLabel, info, status, next, codeLabel, codeInfo, confirm, resend, edit);
|
||||
let disposed = false;
|
||||
let emailRequestId = 0;
|
||||
let confirming = false;
|
||||
@@ -204,6 +207,6 @@ export function render({ navigate }) {
|
||||
} else {
|
||||
showEmail();
|
||||
}
|
||||
screen.append(createTopBar({ title: t('screens.registration_email_view.text_025'), back: { label: '←', onClick: () => { draft.uiStep = 2; navigate('register-view'); } } }), form);
|
||||
screen.append(createTopBar({ title: t('screens.registration_email_view.text_025'), back: { label: '←', onClick: () => { draft.uiStep = 3; navigate('register-view'); } } }), form);
|
||||
return screen;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ function clamp(value, min, max) {
|
||||
}
|
||||
|
||||
export async function completeRegistrationLogin({ navigate, keyBundle }) {
|
||||
const draft = state.registrationDraft;
|
||||
if (![0, 1].includes(draft.accountType)) throw new Error('Missing registration account type');
|
||||
// Финальный вход регистрации нельзя повторять на сокете, который мог
|
||||
// стать авторизованным после частично успешной предыдущей попытки.
|
||||
authService.resetConnection(state.entrySettings.shineServer, { clearSessionContext: true });
|
||||
@@ -115,7 +117,10 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) {
|
||||
// После регистрации оба рабочих ключа сохраняются автоматически.
|
||||
// Приватный Recovery/root key не записывается на устройство.
|
||||
try {
|
||||
await authService.persistSelectedKeys(result.login, result.storagePwd, keyBundle);
|
||||
await authService.persistSelectedKeys(result.login, result.storagePwd, keyBundle, {
|
||||
saveRoot: true, saveBlockchain: true,
|
||||
headerIdentity: { accountType: draft.accountType, previousAccounts: [...draft.previousAccounts] },
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Не удалось сохранить рабочие ключи после регистрации; текущая сессия продолжает работать', error);
|
||||
}
|
||||
@@ -163,6 +168,9 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) {
|
||||
export function render({ navigate }) {
|
||||
const screen = document.createElement('section');
|
||||
screen.className = 'stack';
|
||||
if (![0, 1].includes(state.registrationDraft.accountType) || !state.registrationDraft.preGeneratedKeyBundle) {
|
||||
queueMicrotask(() => navigate('register-view')); return screen;
|
||||
}
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card stack registration-payment-card';
|
||||
@@ -438,14 +446,14 @@ export function render({ navigate }) {
|
||||
card.append(testHint);
|
||||
}
|
||||
card.append(submitButton, status);
|
||||
card.prepend(createRegistrationStepper(3));
|
||||
card.prepend(createRegistrationStepper(4));
|
||||
|
||||
screen.append(
|
||||
createTopBar({
|
||||
title: t('screens.registration_payment_view.text_022'),
|
||||
back: { label: '←', onClick: () => {
|
||||
if (parseBalanceSol(state.registrationPayment.balanceSOL) > 0 && !window.confirm(t('screens.registration_payment_view.text_071'))) return;
|
||||
state.registrationDraft.uiStep = 2; navigate('register-view');
|
||||
state.registrationDraft.uiStep = 3; navigate('register-view');
|
||||
} },
|
||||
}),
|
||||
card,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { confirmationRights } from '../services/account-voting.js';
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
@@ -158,11 +159,8 @@ export function render({ route, chrome }) {
|
||||
}
|
||||
|
||||
function renderBody() {
|
||||
// Те же правила, что проверяет сервер (validateConnectionVotingRights): голосует официальный аккаунт,
|
||||
// за сияние – основной и сам сияющий; цель не должна отказываться от подтверждений.
|
||||
const selfPrimary = selfCard?.accountRole === 'primary';
|
||||
const canPrimary = selfPrimary && targetCard?.accountRole !== 'non_voting';
|
||||
const canShine = selfPrimary && selfCard?.shineStatus === 'shining' && targetCard?.shineStatus !== 'not_interested';
|
||||
// Совпадает с серверными предикатами; отсутствие HEADER не даёт прав.
|
||||
const { primary: canPrimary, shine: canShine } = confirmationRights(selfCard, targetCard);
|
||||
|
||||
body.innerHTML = `
|
||||
<section class="card stack relation-manage-card relation-manage-card--social">
|
||||
@@ -212,6 +210,9 @@ export function render({ route, chrome }) {
|
||||
const social = button.dataset.socialKind;
|
||||
const confirm = button.dataset.confirm;
|
||||
if (!social && !confirm) return;
|
||||
const rights = confirmationRights(selfCard, targetCard);
|
||||
if (confirm === 'official_account' && !rights.primary) return;
|
||||
if (confirm === 'shine_confirmed' && !rights.shine) return;
|
||||
if (social && effectiveSocial(flags, 'out') === social) { navigateBack(); return; }
|
||||
|
||||
const isAttestation = confirm === 'official_account' || confirm === 'shine_confirmed';
|
||||
|
||||
Reference in New Issue
Block a user