diff --git a/shine-UI/js/pages/user-profile-view.js b/shine-UI/js/pages/user-profile-view.js index c3bf2b2c..837a329a 100644 --- a/shine-UI/js/pages/user-profile-view.js +++ b/shine-UI/js/pages/user-profile-view.js @@ -1,8 +1,8 @@ import { renderHeader } from '../components/header.js'; import { SHINE_CONNECTIONS_LOGO_SRC } from '../components/shine-logo.js'; import { renderUserAvatar } from '../components/avatar-image.js'; -import { authService, state } from '../state.js'; -import { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js'; +import { state } from '../state.js'; +import { loadUserProfileCard } from '../services/user-connections.js'; import { makeProfileLinksRoute } from '../services/shine-routes.js'; import { navigateBack } from '../router.js'; @@ -17,13 +17,6 @@ function escapeHtml(text) { .replaceAll("'", '''); } -function effectiveSocial(flags = {}) { - if (flags.outCloseFriend) return 'close_friend'; - if (flags.outFriend) return 'friend'; - if (flags.outContact) return 'contact'; - return 'none'; -} - function metricHtml({ kind, label, value, glow = false, positionClass = '' }) { const numericValue = Number(value || 0); return ` @@ -58,8 +51,8 @@ function openProfileSheet(title, html) { }); } -function aboutSheetHtml(card) { - return `
`; +function spiritualPathSheetHtml(card) { + return ``; } function contactsSheetHtml(card) { @@ -86,20 +79,6 @@ function addIconHtml() { `; } -function relationMenuHtml(flags = {}) { - const current = effectiveSocial(flags); - const rows = [ - ['friend', 'Друг'], - ['close_friend', 'Близкий друг'], - ['contact', 'Контакт'], - ]; - return rows.map(([kind, label]) => ` - `).join(''); -} - export function render({ navigate, route, chrome }) { const requestedLogin = String(route?.params?.login || '').trim(); const selfLogin = String(state.session.login || '').trim(); @@ -122,66 +101,6 @@ export function render({ navigate, route, chrome }) { screen.append(status, body); let card = null; - let relationFlags = null; - let relationLoadPromise = null; - let addMenu = null; - let addActionButton = null; - - function updateRelationUi() { - if (!addMenu) return; - addMenu.innerHTML = relationMenuHtml(relationFlags || {}); - const social = effectiveSocial(relationFlags || {}); - addActionButton?.classList.toggle('is-active', social !== 'none'); - addActionButton?.setAttribute('aria-label', social === 'none' ? 'Добавить' : 'Изменить связь'); - } - - async function ensureRelationFlags() { - if (relationFlags) return relationFlags; - if (relationLoadPromise) return relationLoadPromise; - if (!selfLogin || !card?.login) return {}; - relationLoadPromise = loadRelationsForPair({ currentLogin: selfLogin, targetLogin: card.login }) - .then((flags) => { - relationFlags = flags || {}; - updateRelationUi(); - return relationFlags; - }) - .finally(() => { - relationLoadPromise = null; - }); - return relationLoadPromise; - } - - async function setRelationKind(kind, enabled) { - await authService.setUserRelation({ - login: selfLogin, - toLogin: card.login, - kind, - enabled, - storagePwd: state.session.storagePwdInMemory, - }); - } - - async function changeSocial(next) { - const flags = await ensureRelationFlags(); - const current = effectiveSocial(flags); - if (current === next) return; - - if (next === 'contact') { - if (flags.outCloseFriend) await setRelationKind('close_friend', false); - if (flags.outFriend) await setRelationKind('friend', false); - if (!flags.outContact) await setRelationKind('contact', true); - } - if (next === 'friend') { - if (flags.outCloseFriend) await setRelationKind('close_friend', false); - if (!flags.outFriend) await setRelationKind('friend', true); - } - if (next === 'close_friend' && !flags.outCloseFriend) { - await setRelationKind('close_friend', true); - } - - relationFlags = await loadRelationsForPair({ currentLogin: selfLogin, targetLogin: card.login }); - updateRelationUi(); - } function renderProfile() { if (!card) return; @@ -189,11 +108,18 @@ export function render({ navigate, route, chrome }) { const stats = card.stats || {}; const official = card.accountRole === 'primary'; const shining = card.shineStatus === 'shining'; + const fullName = [card.firstName, card.lastName] + .map((value) => String(value || '').trim()) + .filter(Boolean) + .join(' '); + const about = String(card.about || '').trim(); const title = header.querySelector('.page-title'); if (title) title.textContent = card.login; body.innerHTML = ` + ${fullName ? `` : ''} + -