HEADER v3, primary аккаунты и подтверждения

This commit is contained in:
AidarKC
2026-11-27 12:29:24 +03:00
parent f9e7c4ef94
commit ae430e84c7
89 changed files with 1201 additions and 1596 deletions
+7 -7
View File
@@ -1,3 +1,4 @@
import { accountRoleFromHeader } from './account-voting.js';
import { t } from '../i18n/index.js';
import { authService, state } from '../state.js';
import { validateArweaveTxId } from './arweave-file-service.js';
@@ -119,10 +120,7 @@ export async function loadProfileSnapshot(login) {
}
const latestAccountRole = loadLatestByAliasesFromItems(items, ['account_role']);
const rawAccountRole = String(latestAccountRole?.value || '').trim().toLowerCase();
const accountRole = rawAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY || rawAccountRole === PROFILE_ACCOUNT_ROLE_NON_VOTING
? rawAccountRole
: '';
const accountRole = accountRoleFromHeader(payload?.accountType);
const latestShine = loadLatestByAliasesFromItems(items, ['shine']);
const rawShine = String(latestShine?.value || '').trim().toLowerCase();
@@ -165,6 +163,8 @@ export async function loadProfileSnapshot(login) {
fields,
toggles,
accountRole,
accountType: payload?.accountType ?? null,
previousAccounts: Array.isArray(payload?.previousAccounts) ? payload.previousAccounts : [],
accountRoleTimeMs: latestAccountRole?.timeMs || 0,
shineStatus,
shineTimeMs: latestShine?.timeMs || 0,
@@ -193,8 +193,8 @@ export async function saveProfileParamBlock(login, key, value) {
export async function saveProfileStatus(login, key, value) {
const cleanKey = String(key || '').trim();
const cleanValue = String(value || '').trim().toLowerCase();
if (cleanKey === 'account_role' && ![PROFILE_ACCOUNT_ROLE_PRIMARY, PROFILE_ACCOUNT_ROLE_NON_VOTING].includes(cleanValue)) {
throw new Error(t('remaining.profile_errors.invalid_account_role_value'));
if (['account_role', 'official'].includes(cleanKey.toLowerCase())) {
throw new Error(t('screens.registration_identity.immutable'));
}
if (cleanKey === 'shine' && ![PROFILE_SHINE_SHINING, PROFILE_SHINE_UNKNOWN, PROFILE_SHINE_NOT_INTERESTED].includes(cleanValue)) {
throw new Error(t('remaining.profile_errors.invalid_shine_value'));
@@ -206,7 +206,7 @@ export async function saveProfileStatus(login, key, value) {
// Kept only for old callers outside the current UI. New code must use saveProfileStatus().
export async function saveProfileToggle(login, key, enabled) {
if (key === 'shine') return saveProfileStatus(login, 'shine', enabled ? PROFILE_SHINE_SHINING : PROFILE_SHINE_UNKNOWN);
if (key === 'official') throw new Error(t('remaining.profile_errors.the_official_parameter_is_deprecated_use_account_role'));
if (key === 'official') throw new Error(t('screens.registration_identity.immutable'));
throw new Error(`Неизвестный legacy toggle: ${key}`);
}