SHA256
- Профиль: золотая «дышащая» аура вокруг аватара сияющего, бейджи «Сияющий» / «Официальный» под именем, разделы «Сияние» и «Официальный аккаунт» со списками «кто подтвердил» и «кого подтвердил» (видны у сияющих и у всех, у кого есть подтверждения). - Кнопки подтверждения на экране связи – по тем же правилам, что проверяет сервер (голосует основной аккаунт, за сияние – основной и сияющий; цель не отказалась). - Экран связи: сохранение показывается на нажатой кнопке, без строки «Сохранение…», которая сдвигала экран; после выбора – сообщение и возврат на страницу пользователя. - В каналах и обсуждениях аватары без стеклянного кольца «Связей» (готовый avatar-plain). - Локальный сервер UI отдаёт Cache-Control: no-cache – иначе браузер брал старый router.js.
108 lines
3.7 KiB
JavaScript
108 lines
3.7 KiB
JavaScript
import { createTopBar } from '../components/topbar.js';
|
|
import { SHINE_CONNECTIONS_LOGO_SRC } from '../components/shine-logo.js';
|
|
import { renderUserAvatar } from '../components/avatar-image.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';
|
|
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
|
|
|
|
export const pageMeta = { id: 'user', title: 'Профиль' };
|
|
|
|
function escapeHtml(text) {
|
|
return String(text || '')
|
|
.replaceAll('&', '&')
|
|
.replaceAll('<', '<')
|
|
.replaceAll('>', '>')
|
|
.replaceAll('"', '"')
|
|
.replaceAll("'", ''');
|
|
}
|
|
|
|
export function render({ navigate, route, chrome }) {
|
|
const requestedLogin = String(route?.params?.login || '').trim();
|
|
const selfLogin = String(state.session.login || '').trim();
|
|
const screen = document.createElement('section');
|
|
screen.className = 'stack user-profile-screen';
|
|
|
|
const header = createTopBar({
|
|
title: 'Профиль',
|
|
back: { label: '←', onClick: () => navigateBack() },
|
|
});
|
|
header.classList.add('user-profile-header');
|
|
chrome?.setTopbar(header);
|
|
|
|
const status = document.createElement('div');
|
|
status.className = 'status-line user-profile-status';
|
|
status.textContent = 'Загрузка профиля...';
|
|
|
|
const body = document.createElement('div');
|
|
body.className = 'user-profile-body';
|
|
screen.append(status, body);
|
|
|
|
let card = null;
|
|
function renderProfile() {
|
|
if (!card) return;
|
|
const isSelf = card.login.toLowerCase() === selfLogin.toLowerCase();
|
|
|
|
body.innerHTML = profileCardHtml({
|
|
card,
|
|
login: requestedLogin,
|
|
isSelf,
|
|
tilesHtml: isSelf ? '' : [
|
|
profileTileHtml({ icon: 'user-plus', label: 'Добавить связь', attrs: 'data-profile-action="add"' }),
|
|
profileTileHtml({ label: 'Связи', attrs: 'data-profile-action="links"', iconMarkup: `<img class="pf-tile-mandala" src="${SHINE_CONNECTIONS_LOGO_SRC}" alt="" aria-hidden="true">` }),
|
|
profileTileHtml({ icon: 'message', label: 'Написать', attrs: 'data-profile-action="chat"' }),
|
|
].join(''),
|
|
});
|
|
|
|
const avatarSlot = body.querySelector('.user-profile-avatar-slot');
|
|
avatarSlot?.append(renderUserAvatar({
|
|
login: card.login,
|
|
firstName: card.firstName,
|
|
lastName: card.lastName,
|
|
avatar: card.avatar,
|
|
size: 'xl',
|
|
className: 'user-profile-hero-avatar',
|
|
official: card.accountRole === 'primary',
|
|
}));
|
|
|
|
status.textContent = '';
|
|
}
|
|
|
|
body.addEventListener('click', (event) => {
|
|
if (!card) return;
|
|
const listButton = event.target.closest('[data-profile-list]');
|
|
if (listButton) {
|
|
const kind = listButton.dataset.profileList;
|
|
if (kind) navigate(`SHiNE/${encodeURIComponent(card.login)}/list/${encodeURIComponent(kind)}`);
|
|
return;
|
|
}
|
|
|
|
const actionButton = event.target.closest('[data-profile-action]');
|
|
const action = actionButton?.dataset.profileAction;
|
|
if (action === 'add') {
|
|
navigate(`SHiNE/${encodeURIComponent(card.login)}/manage`);
|
|
return;
|
|
}
|
|
if (action === 'links') {
|
|
navigate(makeProfileLinksRoute(card.login));
|
|
return;
|
|
}
|
|
if (action === 'chat') {
|
|
navigate(`chat/${encodeURIComponent(card.login)}`);
|
|
}
|
|
});
|
|
|
|
async function refresh() {
|
|
card = await loadUserProfileCard(requestedLogin);
|
|
renderProfile();
|
|
}
|
|
|
|
refresh().catch((error) => {
|
|
status.className = 'status-line user-profile-status is-unavailable';
|
|
status.textContent = `Ошибка: ${error?.message || 'unknown'}`;
|
|
});
|
|
|
|
return screen;
|
|
}
|