SHA256
Отключить мультиаккаунтность и уточнить статусы профиля
This commit is contained in:
@@ -2,7 +2,6 @@ import { t } from '../i18n/index.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import {
|
||||
authService,
|
||||
cancelAddProfileLogin,
|
||||
clearAuthMessages,
|
||||
setAuthBusy,
|
||||
setAuthError,
|
||||
@@ -160,11 +159,6 @@ export function render({ navigate }) {
|
||||
back: {
|
||||
label: '←',
|
||||
onClick: async () => {
|
||||
if (state.authReturnHash === '/profiles') {
|
||||
await cancelAddProfileLogin();
|
||||
navigate('profiles-view');
|
||||
return;
|
||||
}
|
||||
navigate('start-view');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -22,9 +22,6 @@ export const pageMeta = {
|
||||
},
|
||||
};
|
||||
|
||||
const GENDER_MALE = 'male';
|
||||
const GENDER_FEMALE = 'female';
|
||||
const GENDER_UNKNOWN = 'unknown';
|
||||
|
||||
function normalizeLogin(value) {
|
||||
return String(value || '').trim();
|
||||
@@ -64,13 +61,6 @@ function escapeHtml(text) {
|
||||
.replaceAll("'", ''');
|
||||
}
|
||||
|
||||
function normalizeGender(value) {
|
||||
const clean = String(value || '').trim().toLowerCase();
|
||||
if (clean === GENDER_MALE) return GENDER_MALE;
|
||||
if (clean === GENDER_FEMALE) return GENDER_FEMALE;
|
||||
return GENDER_UNKNOWN;
|
||||
}
|
||||
|
||||
function toSet(list) {
|
||||
return new Set(uniqueLogins(list).map((value) => normKey(value)));
|
||||
}
|
||||
@@ -117,24 +107,6 @@ function normalizeAvatar(row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function applyRelativeGender(map, rows) {
|
||||
(Array.isArray(rows) ? rows : []).forEach((row) => {
|
||||
const login = normalizeLogin(row?.login);
|
||||
if (!login) return;
|
||||
const key = normKey(login);
|
||||
const gender = normalizeGender(row?.gender);
|
||||
const prev = map.get(key) || GENDER_UNKNOWN;
|
||||
if (prev === GENDER_UNKNOWN || gender !== GENDER_UNKNOWN) map.set(key, gender);
|
||||
});
|
||||
}
|
||||
|
||||
function getRelativeGenderMap(graph) {
|
||||
const map = new Map();
|
||||
// Родственные связи пока скрыты из UI, хотя сервер продолжает хранить их коды.
|
||||
void graph;
|
||||
return map;
|
||||
}
|
||||
|
||||
function buildGraphModel(graph, centerLogin) {
|
||||
const login = normalizeLogin(graph?.login || centerLogin || state.session.login);
|
||||
const outFriends = toSet(graph?.outFriends);
|
||||
@@ -156,7 +128,6 @@ function buildGraphModel(graph, centerLogin) {
|
||||
role: 'friend',
|
||||
relationType: hasLogin(outCloseFriends, targetLogin) ? 'close_friend' : 'friend',
|
||||
isRelative: false,
|
||||
gender: GENDER_UNKNOWN,
|
||||
forward: true,
|
||||
backward: hasLogin(inCloseFriends, targetLogin) || hasLogin(inFriends, targetLogin),
|
||||
mark: allMarks.get(normKey(targetLogin)) || null,
|
||||
|
||||
@@ -22,16 +22,8 @@ const CONNECTION_OFFICIAL_UNCONFIRMED = 81;
|
||||
const profileSnapshotCache = new Map();
|
||||
const profileSnapshotPending = new Map();
|
||||
|
||||
// Глагол по полу из профиля автора («Добавила вас в друзья»); пока профиль не пришёл или пол
|
||||
// не указан – нейтральное «Добавил(а)».
|
||||
function byGender(gender, male, female, neutral) {
|
||||
if (gender === 'male') return male;
|
||||
if (gender === 'female') return female;
|
||||
return neutral;
|
||||
}
|
||||
|
||||
function connectionActionLabel(typeCode, gender = '') {
|
||||
const verb = (male, female) => byGender(gender, male, female, t('screens.notifications_view.text_032', { value1: male }));
|
||||
function connectionActionLabel(typeCode) {
|
||||
const verb = (male, female) => t('screens.notifications_view.text_032', { value1: male });
|
||||
switch (Number(typeCode)) {
|
||||
case CONNECTION_CLOSE_FRIEND: return t('screens.notifications_view.text_033', { value1: verb(t('screens.notifications_view.text_047'), t('screens.notifications_view.text_048')) });
|
||||
case CONNECTION_UNCLOSE_FRIEND: return t('screens.notifications_view.text_034', { value1: verb(t('screens.notifications_view.text_049'), t('screens.notifications_view.text_050')) });
|
||||
@@ -45,16 +37,15 @@ function connectionActionLabel(typeCode, gender = '') {
|
||||
}
|
||||
}
|
||||
|
||||
function eventActionLabel(typeCode, gender = '') {
|
||||
if (Number(typeCode) === CONNECTION_UNFOLLOW) return t('screens.notifications_view.text_042', { value1: byGender(gender, t('screens.notifications_view.text_065'), t('screens.notifications_view.text_066'), t('screens.notifications_view.text_067')) });
|
||||
return t('screens.notifications_view.text_043', { value1: byGender(gender, t('screens.notifications_view.text_068'), t('screens.notifications_view.text_069'), t('screens.notifications_view.text_070')) });
|
||||
function eventActionLabel(typeCode) {
|
||||
if (Number(typeCode) === CONNECTION_UNFOLLOW) return t('screens.notifications_view.text_042', { value1: t('screens.notifications_view.text_067') });
|
||||
return t('screens.notifications_view.text_043', { value1: t('screens.notifications_view.text_070') });
|
||||
}
|
||||
|
||||
function actionLabel(item, activeTab) {
|
||||
const gender = String(item.profile?.gender || '');
|
||||
return activeTab === 'connections'
|
||||
? connectionActionLabel(item.connectionTypeCode ?? item.sourceMsgSubType, gender)
|
||||
: eventActionLabel(item.sourceMsgSubType, gender);
|
||||
? connectionActionLabel(item.connectionTypeCode ?? item.sourceMsgSubType)
|
||||
: eventActionLabel(item.sourceMsgSubType);
|
||||
}
|
||||
|
||||
function reciprocalRelationKind(item) {
|
||||
|
||||
@@ -8,14 +8,10 @@ import { showToast } from '../services/channels-ux.js';
|
||||
import { profile } from '../mock-data.js';
|
||||
import { authService, state } from '../state.js';
|
||||
import {
|
||||
PROFILE_GENDER_FEMALE,
|
||||
PROFILE_GENDER_MALE,
|
||||
PROFILE_GENDER_UNKNOWN,
|
||||
PROFILE_ACCOUNT_ROLE_PRIMARY,
|
||||
PROFILE_SHINE_SHINING,
|
||||
PROFILE_SHINE_UNKNOWN,
|
||||
loadProfileSnapshot,
|
||||
saveProfileGender,
|
||||
saveProfileParamBlock,
|
||||
saveProfileStatus,
|
||||
} from '../services/user-profile-params.js';
|
||||
@@ -25,10 +21,6 @@ import { renderUserAvatar } from '../components/avatar-image.js';
|
||||
|
||||
export const pageMeta = { id: 'profile-edit-view', get title() { return t('screens.profile_edit_view.text_001'); } };
|
||||
|
||||
function accountRoleLabel(value) {
|
||||
return value === PROFILE_ACCOUNT_ROLE_PRIMARY ? t('screens.profile_edit_view.text_009') : t('screens.profile_edit_view.text_010');
|
||||
}
|
||||
|
||||
function shineStatusLabel(value) {
|
||||
return value === PROFILE_SHINE_SHINING ? t('screens.profile_edit_view.text_011') : t('screens.profile_edit_view.text_012');
|
||||
}
|
||||
@@ -53,18 +45,6 @@ function showLocalErrorAlert(prefix, error) {
|
||||
showToast(`${prefix}. ${toUserMessage(error, t('screens.profile_edit_view.text_006'))}`, { kind: 'error' });
|
||||
}
|
||||
|
||||
function genderLabel(value) {
|
||||
if (value === PROFILE_GENDER_MALE) return t('screens.profile_edit_view.text_013');
|
||||
if (value === PROFILE_GENDER_FEMALE) return t('screens.profile_edit_view.text_014');
|
||||
return t('screens.profile_edit_view.text_015');
|
||||
}
|
||||
|
||||
const GENDER_OPTIONS = Object.freeze([
|
||||
{ value: PROFILE_GENDER_MALE, get label() { return t('screens.profile_edit_view.text_002'); } },
|
||||
{ value: PROFILE_GENDER_FEMALE, get label() { return t('screens.profile_edit_view.text_003'); } },
|
||||
{ value: PROFILE_GENDER_UNKNOWN, get label() { return t('screens.profile_edit_view.text_004'); } },
|
||||
]);
|
||||
|
||||
function escapeHtml(text) {
|
||||
return String(text || '')
|
||||
.replaceAll('&', '&')
|
||||
@@ -107,7 +87,7 @@ export function render({ navigate, chrome }) {
|
||||
const badgesRow = document.createElement('div');
|
||||
badgesRow.className = 'chip-row profile-edit-statuses';
|
||||
badgesRow.innerHTML = `
|
||||
<span class="badge is-no" data-status="account_role">${th('screens.profile_edit_view.text_029')}</span>
|
||||
<button type="button" class="badge profile-account-info is-no" data-status="account_role">${th('screens.registration_identity.alternative_button')}</button>
|
||||
<button class="chip profile-toggle-btn is-no" type="button" data-status="shine">${th('screens.profile_edit_view.text_030')}</button>
|
||||
`;
|
||||
|
||||
@@ -125,66 +105,12 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
let currentFields = [];
|
||||
let currentAccountRole = '';
|
||||
let currentAccountType = null;
|
||||
let currentShineStatus = '';
|
||||
let currentGender = PROFILE_GENDER_UNKNOWN;
|
||||
let statusFlowOpen = false;
|
||||
let currentAvatar = { value: '', source: '', txId: '', pr: '', timeMs: 0 };
|
||||
const identityEl = topRow.querySelector('[data-profile-identity="true"]');
|
||||
const avatarSlotEl = topRow.querySelector('[data-profile-avatar-slot="true"]');
|
||||
|
||||
function openGenderPickerModal(initialGender) {
|
||||
const root = document.getElementById('modal-root');
|
||||
if (!root) return Promise.resolve(null);
|
||||
root.innerHTML = '';
|
||||
|
||||
const selected = GENDER_OPTIONS.some((item) => item.value === initialGender)
|
||||
? initialGender
|
||||
: PROFILE_GENDER_UNKNOWN;
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="modal" id="profile-gender-modal">
|
||||
<div class="modal-card stack">
|
||||
<h3 class="modal-title">${t('dialogs.modals.profile_edit_view.label_001')}</h3>
|
||||
<p class="meta-muted">${t('dialogs.modals.profile_edit_view.label_002')}</p>
|
||||
<select class="input profile-gender-select" id="profile-gender-select">
|
||||
${GENDER_OPTIONS.map((item) => (
|
||||
`<option value="${item.value}" ${item.value === selected ? 'selected' : ''}>${item.label}</option>`
|
||||
)).join('')}
|
||||
</select>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" id="profile-gender-cancel" type="button">${t('dialogs.remaining.pages.profile_edit_view.markup.otmena')}</button>
|
||||
<button class="primary-btn" id="profile-gender-save" type="button">${t('dialogs.remaining.pages.profile_edit_view.markup.sohranit')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const modal = root.querySelector('#profile-gender-modal');
|
||||
const selectEl = root.querySelector('#profile-gender-select');
|
||||
const saveEl = root.querySelector('#profile-gender-save');
|
||||
const cancelEl = root.querySelector('#profile-gender-cancel');
|
||||
if (!(modal instanceof HTMLElement) || !(selectEl instanceof HTMLSelectElement)) {
|
||||
root.innerHTML = '';
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const close = (value = null) => {
|
||||
root.innerHTML = '';
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
modal.addEventListener('click', (event) => {
|
||||
if (event.target === modal) close(null);
|
||||
});
|
||||
cancelEl?.addEventListener('click', () => close(null));
|
||||
saveEl?.addEventListener('click', () => close(selectEl.value || PROFILE_GENDER_UNKNOWN));
|
||||
window.setTimeout(() => selectEl.focus(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
function syncIdentity() {
|
||||
if (!identityEl) return;
|
||||
const firstName = currentFields.find((field) => field.key === 'first_name')?.value || '';
|
||||
@@ -217,9 +143,7 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
function updateStatusesUi() {
|
||||
if (accountRoleBtn) {
|
||||
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.textContent = t(currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY ? 'screens.registration_identity.official_button' : 'screens.registration_identity.alternative_button');
|
||||
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');
|
||||
}
|
||||
@@ -231,12 +155,6 @@ export function render({ navigate, chrome }) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateGenderUi() {
|
||||
const genderValueEl = listWrap.querySelector('[data-gender-value]');
|
||||
if (!genderValueEl) return;
|
||||
genderValueEl.textContent = genderLabel(currentGender);
|
||||
}
|
||||
|
||||
function openFieldEditModal({ label, value, placeholder = '', maxLength = 300, multiline = false, suggestions = null }) {
|
||||
const root = document.getElementById('modal-root');
|
||||
if (!root) return Promise.resolve(null);
|
||||
@@ -314,16 +232,6 @@ export function render({ navigate, chrome }) {
|
||||
row.innerHTML = `<span class="nav-row__hint">${escapeHtml(field.label)}</span><span class="nav-row__label${value ? '' : ' is-empty'}">${escapeHtml(value || t('screens.profile_edit_view.text_019'))}</span>`;
|
||||
listWrap.append(row);
|
||||
|
||||
if (field.key === 'last_name') {
|
||||
const genderRow = document.createElement('button');
|
||||
genderRow.type = 'button';
|
||||
genderRow.className = 'nav-row profile-param-item';
|
||||
genderRow.dataset.editGender = 'true';
|
||||
const genderText = genderLabel(currentGender);
|
||||
const genderEmpty = currentGender !== PROFILE_GENDER_MALE && currentGender !== PROFILE_GENDER_FEMALE;
|
||||
genderRow.innerHTML = `<span class="nav-row__hint">${th('screens.profile_edit_view.text_031')}</span><span class="nav-row__label${genderEmpty ? ' is-empty' : ''}" data-gender-value>${escapeHtml(genderEmpty ? t('screens.profile_edit_view.text_016') : genderText)}</span>`;
|
||||
listWrap.append(genderRow);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -337,15 +245,12 @@ export function render({ navigate, chrome }) {
|
||||
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 };
|
||||
|
||||
syncIdentity();
|
||||
renderFields(currentFields);
|
||||
updateStatusesUi();
|
||||
updateGenderUi();
|
||||
updateAvatarUi();
|
||||
|
||||
status.className = 'status-line';
|
||||
@@ -462,38 +367,9 @@ export function render({ navigate, chrome }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function onGenderClick() {
|
||||
const nextGender = await openGenderPickerModal(currentGender);
|
||||
if (!nextGender || nextGender === currentGender) return;
|
||||
const accepted = await confirmPublicHistoryAction({
|
||||
title: t('dialogs.final.consent.gender_publish_title'),
|
||||
text: t('dialogs.final.consent.public_history_warning'),
|
||||
confirmLabel: t('dialogs.final.consent.record_yes'),
|
||||
cancelLabel: t('dialogs.final.consent.record_no'),
|
||||
});
|
||||
if (!accepted || !screen.isConnected) return;
|
||||
|
||||
status.className = 'status-line';
|
||||
status.textContent = t('dialogs.modals.profile_edit_view.label_009');
|
||||
|
||||
try {
|
||||
await saveProfileGender(login, nextGender);
|
||||
await refreshProfileSnapshot();
|
||||
} catch (error) {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = t('screens.profile_edit_view.text_027', { value1: toUserMessage(error, t('dialogs.modals.profile_edit_view.label_010')) });
|
||||
showLocalErrorAlert(t('screens.profile_edit_view.text_008'), error);
|
||||
}
|
||||
}
|
||||
|
||||
listWrap.addEventListener('click', (event) => {
|
||||
const target = event.target;
|
||||
if (!(target instanceof HTMLElement)) return;
|
||||
const genderRow = target.closest('[data-edit-gender="true"]');
|
||||
if (genderRow) {
|
||||
onGenderClick();
|
||||
return;
|
||||
}
|
||||
const fieldRow = target.closest('[data-edit-field]');
|
||||
const fieldKey = String(fieldRow?.getAttribute('data-edit-field') || '');
|
||||
if (!fieldKey) return;
|
||||
@@ -501,7 +377,10 @@ export function render({ navigate, chrome }) {
|
||||
});
|
||||
|
||||
reloadBtn.addEventListener('click', refreshProfileSnapshot);
|
||||
accountRoleBtn.title = t('screens.registration_identity.immutable');
|
||||
accountRoleBtn.addEventListener('click', () => {
|
||||
const official = currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY;
|
||||
void confirmDialog({ title: accountRoleBtn.textContent, text: t(official ? 'screens.registration_identity.official_help' : 'screens.registration_identity.alternative_help') + '\n\n' + t('screens.registration_identity.immutable'), confirmLabel: t('screens.registration_identity.ok'), infoOnly: true });
|
||||
});
|
||||
shineBtn.addEventListener('click', () => onStatusClick('shine'));
|
||||
avatarActionEl?.addEventListener('click', () => { void onChangeAvatarClick(); });
|
||||
|
||||
|
||||
@@ -62,10 +62,7 @@ export function render({ navigate, chrome }) {
|
||||
profileTileHtml({ icon: 'wallet', label: t('screens.profile_view.text_008'), attrs: 'data-self-profile-action="wallet"' }),
|
||||
profileTileHtml({ icon: 'settings', label: t('screens.profile_view.text_009'), attrs: 'data-self-profile-action="settings"' }),
|
||||
].join(''),
|
||||
}) + `
|
||||
<div class="nav-list profile-more-list">
|
||||
<button class="nav-row" type="button" data-self-profile-action="profiles"><span class="nav-row__label">${th('screens.profile_view.text_015')}</span><span class="nav-row__hint">${th('screens.profile_view.text_016')}</span></button>
|
||||
</div>`;
|
||||
});
|
||||
|
||||
attachSupportStats(body, { login: card.login || login, isActive: () => !disposed });
|
||||
avatarPreview = attachProfileAvatarPreview(body.querySelector('.user-profile-avatar-slot'), card);
|
||||
@@ -89,7 +86,6 @@ export function render({ navigate, chrome }) {
|
||||
if (action === 'edit') navigate('profile-edit-view');
|
||||
if (action === 'wallet') navigate('wallet-view');
|
||||
if (action === 'settings') navigate('settings-view');
|
||||
if (action === 'profiles') navigate('profiles-view');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { t } from '../i18n/index.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import {
|
||||
MULTI_PROFILE_ENABLED,
|
||||
closeAllSavedProfiles,
|
||||
closeSavedProfile,
|
||||
getSavedProfiles,
|
||||
@@ -18,6 +19,10 @@ function reloadTo(path) {
|
||||
}
|
||||
|
||||
export function render({navigate, chrome}) {
|
||||
if (!MULTI_PROFILE_ENABLED) {
|
||||
queueMicrotask(() => navigate('profile-view'));
|
||||
return document.createElement('section');
|
||||
}
|
||||
const screen = document.createElement('section');
|
||||
screen.className = 'stack profiles-screen';
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@ export function render({ navigate }) {
|
||||
return window.confirm(t('screens.register_view.text_039'));
|
||||
}
|
||||
function goBack() {
|
||||
if (Number(draft.uiStep) === 4) {
|
||||
showAccountType();
|
||||
return;
|
||||
}
|
||||
if (Number(draft.uiStep) === 3) {
|
||||
showPassword();
|
||||
return;
|
||||
@@ -70,7 +74,7 @@ export function render({ navigate }) {
|
||||
}
|
||||
function showLogin() {
|
||||
draft.uiStep = 1;
|
||||
body.replaceChildren(createRegistrationStepper(1));
|
||||
body.replaceChildren(createRegistrationStepper(1, draft.accountType === 1 ? 5 : 4));
|
||||
const [heading, description] = title(t('screens.register_view.text_014'), t('screens.register_view.text_015'));
|
||||
const label = document.createElement('label');
|
||||
label.className = 'stack';
|
||||
@@ -143,7 +147,7 @@ export function render({ navigate }) {
|
||||
}
|
||||
function showPassword() {
|
||||
draft.uiStep = 2;
|
||||
body.replaceChildren(createRegistrationStepper(2));
|
||||
body.replaceChildren(createRegistrationStepper(2, draft.accountType === 1 ? 5 : 4));
|
||||
const [heading, description] = title(t('screens.register_view.text_016'), t('screens.register_view.text_017'));
|
||||
const label = document.createElement('label');
|
||||
label.className = 'stack';
|
||||
@@ -238,7 +242,7 @@ export function render({ navigate }) {
|
||||
|
||||
function showAccountType() {
|
||||
draft.uiStep = 3;
|
||||
body.replaceChildren(createRegistrationStepper(3));
|
||||
body.replaceChildren(createRegistrationStepper(3, draft.accountType === 1 ? 5 : 4));
|
||||
const tr = key => t(`screens.registration_identity.${key}`);
|
||||
const [heading, description] = title(tr('title'), tr('immutable'));
|
||||
const choices = document.createElement('div'); choices.className = 'stack';
|
||||
@@ -249,12 +253,33 @@ export function render({ navigate }) {
|
||||
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(); });
|
||||
radio.addEventListener('change', () => { draft.accountType = type; next.disabled = false; body.firstElementChild.replaceWith(createRegistrationStepper(3, type === 1 ? 5 : 4)); });
|
||||
};
|
||||
option(1, 'primary', 'primary_detail');
|
||||
option(0, 'alternative', 'alternative_detail');
|
||||
const status = statusLine();
|
||||
const next = document.createElement('button'); next.type = 'button'; next.className = 'primary-btn signup-next'; next.textContent = tr('next');
|
||||
next.disabled = ![0, 1].includes(draft.accountType);
|
||||
next.addEventListener('click', () => {
|
||||
if (draft.accountType === 1) showPreviousAccounts();
|
||||
else if (draft.accountType === 0) { draft.previousAccounts = []; finishIdentity(status); }
|
||||
});
|
||||
body.append(heading, description, choices, status, next);
|
||||
}
|
||||
|
||||
function finishIdentity(status) {
|
||||
try {
|
||||
savePendingHeaderIdentity(draft.login, draft.preGeneratedKeyBundle?.blockchainPair?.publicKeyB64, draft);
|
||||
navigate(flowType === 'free' ? 'registration-email-view' : 'registration-payment-view');
|
||||
} catch (error) { status.textContent = error.message; }
|
||||
}
|
||||
|
||||
function showPreviousAccounts() {
|
||||
draft.uiStep = 4;
|
||||
body.replaceChildren(createRegistrationStepper(4, 5));
|
||||
const tr = key => t(`screens.registration_identity.${key}`);
|
||||
const [heading, description] = title(tr('previous_title'), tr('previous_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');
|
||||
@@ -264,12 +289,10 @@ export function render({ navigate }) {
|
||||
const results = document.createElement('div'); results.className = 'stack';
|
||||
const status = statusLine();
|
||||
searchBox.append(input, search, results);
|
||||
previous.append(explanation, list, add, searchBox, disclosure);
|
||||
previous.append(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';
|
||||
@@ -289,7 +312,7 @@ export function render({ navigate }) {
|
||||
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;
|
||||
if (!screen.isConnected || draft.uiStep !== 4 || 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 || '');
|
||||
@@ -306,22 +329,16 @@ export function render({ navigate }) {
|
||||
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();
|
||||
next.addEventListener('click', () => finishIdentity(status));
|
||||
body.append(heading, description, previous, status, next); refresh();
|
||||
}
|
||||
|
||||
if (flowType !== 'free' && flowType !== 'paid') {
|
||||
queueMicrotask(() => navigate('registration-choice-view'));
|
||||
return screen;
|
||||
}
|
||||
if (Number(draft.uiStep) === 3 && draft.login && draft.preGeneratedKeyBundle) showAccountType();
|
||||
if (Number(draft.uiStep) === 4 && draft.accountType === 1 && draft.login && draft.preGeneratedKeyBundle) showPreviousAccounts();
|
||||
else if (Number(draft.uiStep) === 3 && draft.login && draft.preGeneratedKeyBundle) showAccountType();
|
||||
else if (Number(draft.uiStep) === 2 && draft.login) showPassword();
|
||||
else showLogin();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ export function render({ navigate }) {
|
||||
edit.className = 'ghost-btn';
|
||||
edit.textContent = t('screens.registration_email_view.text_011');
|
||||
|
||||
form.append(createRegistrationStepper(4), title, lead, inputLabel, info, status, next, codeLabel, codeInfo, confirm, resend, edit);
|
||||
form.append(createRegistrationStepper(state.registrationDraft.accountType === 1 ? 5 : 4, state.registrationDraft.accountType === 1 ? 5 : 4), title, lead, inputLabel, info, status, next, codeLabel, codeInfo, confirm, resend, edit);
|
||||
let disposed = false;
|
||||
let emailRequestId = 0;
|
||||
let confirming = false;
|
||||
@@ -207,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 = 3; navigate('register-view'); } } }), form);
|
||||
screen.append(createTopBar({ title: t('screens.registration_email_view.text_025'), back: { label: '←', onClick: () => { draft.uiStep = draft.accountType === 1 ? 4 : 3; navigate('register-view'); } } }), form);
|
||||
return screen;
|
||||
}
|
||||
|
||||
@@ -446,14 +446,14 @@ export function render({ navigate }) {
|
||||
card.append(testHint);
|
||||
}
|
||||
card.append(submitButton, status);
|
||||
card.prepend(createRegistrationStepper(4));
|
||||
card.prepend(createRegistrationStepper(state.registrationDraft.accountType === 1 ? 5 : 4, state.registrationDraft.accountType === 1 ? 5 : 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 = 3; navigate('register-view');
|
||||
state.registrationDraft.uiStep = state.registrationDraft.accountType === 1 ? 4 : 3; navigate('register-view');
|
||||
} },
|
||||
}),
|
||||
card,
|
||||
|
||||
@@ -91,7 +91,7 @@ export function render({ navigate, route, chrome }) {
|
||||
else if (theyFriend) { label = t('screens.user_profile_view.text_016'); hint = t('screens.user_profile_view.text_017'); }
|
||||
else if (r.inContact) {
|
||||
label = t('screens.user_profile_view.text_018');
|
||||
hint = t('screens.user_profile_view.text_019', { value1: card.gender === 'female' ? t('screens.user_profile_view.text_010') : card.gender === 'male' ? t('screens.user_profile_view.text_011') : t('screens.user_profile_view.text_012') });
|
||||
hint = t('screens.user_profile_view.text_019', { value1: t('screens.user_profile_view.text_012') });
|
||||
}
|
||||
tile.innerHTML = `${iconHtml(icon)}<span></span>`;
|
||||
tile.querySelector('span').textContent = label;
|
||||
|
||||
Reference in New Issue
Block a user