SHA256
UI: сияние в профиле, связь без сдвига экрана, аватары каналов без кольца
- Профиль: золотая «дышащая» аура вокруг аватара сияющего, бейджи «Сияющий» / «Официальный» под именем, разделы «Сияние» и «Официальный аккаунт» со списками «кто подтвердил» и «кого подтвердил» (видны у сияющих и у всех, у кого есть подтверждения). - Кнопки подтверждения на экране связи – по тем же правилам, что проверяет сервер (голосует основной аккаунт, за сияние – основной и сияющий; цель не отказалась). - Экран связи: сохранение показывается на нажатой кнопке, без строки «Сохранение…», которая сдвигала экран; после выбора – сообщение и возврат на страницу пользователя. - В каналах и обсуждениях аватары без стеклянного кольца «Связей» (готовый avatar-plain). - Локальный сервер UI отдаёт Cache-Control: no-cache – иначе браузер брал старый router.js.
This commit is contained in:
@@ -3,6 +3,8 @@ import { authService, state } from '../state.js';
|
||||
import { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js';
|
||||
import { navigateBack } from '../router.js';
|
||||
import { escapeProfileHtml } from '../components/profile-card.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
|
||||
export const pageMeta = { id: 'user-relation-manage-view', title: 'Добавить связь' };
|
||||
|
||||
@@ -62,12 +64,12 @@ function socialButtonsHtml(flags = {}) {
|
||||
</button>`).join('');
|
||||
}
|
||||
|
||||
function officialBlockHtml(flags = {}) {
|
||||
function officialBlockHtml(flags = {}, targetIsOfficial = false) {
|
||||
return `
|
||||
<section class="card stack relation-manage-card relation-manage-card--official">
|
||||
<div class="relation-manage-card-head">
|
||||
<strong>Основной аккаунт</strong>
|
||||
<span>Этот аккаунт — основной</span>
|
||||
<span>${targetIsOfficial ? 'Этот аккаунт отмечен как основной' : 'Подтвердите, если это основной аккаунт этого человека'}</span>
|
||||
</div>
|
||||
<div class="relation-manage-confirmations">
|
||||
${flags.outOfficialAccount ? '<div class="relation-manage-confirmation">✓ Вы подтвердили его основной аккаунт</div>' : ''}
|
||||
@@ -79,12 +81,12 @@ function officialBlockHtml(flags = {}) {
|
||||
</section>`;
|
||||
}
|
||||
|
||||
function shineBlockHtml(flags = {}) {
|
||||
function shineBlockHtml(flags = {}, targetIsShining = false) {
|
||||
return `
|
||||
<section class="card stack relation-manage-card relation-manage-card--shine">
|
||||
<div class="relation-manage-card-head">
|
||||
<strong>Сияющий</strong>
|
||||
<span>Этот аккаунт — сияющий</span>
|
||||
<span>${targetIsShining ? 'Этот человек отмечен как сияющий' : 'Подтвердите, если считаете этого человека сияющим'}</span>
|
||||
</div>
|
||||
<div class="relation-manage-confirmations">
|
||||
${flags.outShineConfirmed ? '<div class="relation-manage-confirmation">✓ Вы подтверждаете его сияющим</div>' : ''}
|
||||
@@ -152,8 +154,11 @@ export function render({ route, chrome }) {
|
||||
}
|
||||
|
||||
function renderBody() {
|
||||
const canPrimary = selfCard?.accountRole === 'primary' && targetCard?.accountRole === 'primary';
|
||||
const canShine = selfCard?.shineStatus === 'shining' && targetCard?.shineStatus === 'shining';
|
||||
// Те же правила, что проверяет сервер (validateConnectionVotingRights): голосует основной аккаунт,
|
||||
// за сияние – основной и сам сияющий; цель не должна отказываться от подтверждений.
|
||||
const selfPrimary = selfCard?.accountRole === 'primary';
|
||||
const canPrimary = selfPrimary && targetCard?.accountRole !== 'non_voting';
|
||||
const canShine = selfPrimary && selfCard?.shineStatus === 'shining' && targetCard?.shineStatus !== 'not_interested';
|
||||
|
||||
body.innerHTML = `
|
||||
<section class="card stack relation-manage-card relation-manage-card--social">
|
||||
@@ -166,26 +171,36 @@ export function render({ route, chrome }) {
|
||||
${socialButtonsHtml(flags)}
|
||||
</div>
|
||||
</section>
|
||||
${canPrimary ? officialBlockHtml(flags) : ''}
|
||||
${canShine ? shineBlockHtml(flags) : ''}
|
||||
${canPrimary ? officialBlockHtml(flags, targetCard?.accountRole === 'primary') : ''}
|
||||
${canShine ? shineBlockHtml(flags, targetCard?.shineStatus === 'shining') : ''}
|
||||
`;
|
||||
}
|
||||
|
||||
async function refresh({ loading = true } = {}) {
|
||||
if (loading) {
|
||||
status.className = 'status-line relation-manage-status';
|
||||
status.textContent = 'Загрузка...';
|
||||
}
|
||||
// «Загрузка…» – только если ответ задержался, иначе строка мелькает и сдвигает экран.
|
||||
const loadingTimer = loading ? window.setTimeout(() => {
|
||||
if (screen.isConnected && !body.childElementCount) status.textContent = 'Загрузка…';
|
||||
}, 500) : 0;
|
||||
[selfCard, targetCard, flags] = await Promise.all([
|
||||
loadUserProfileCard(selfLogin),
|
||||
loadUserProfileCard(targetLogin),
|
||||
loadRelationsForPair({ currentLogin: selfLogin, targetLogin }),
|
||||
]);
|
||||
window.clearTimeout(loadingTimer);
|
||||
renderBody();
|
||||
status.className = 'status-line relation-manage-status';
|
||||
status.textContent = '';
|
||||
}
|
||||
|
||||
const SOCIAL_DONE = {
|
||||
none: 'Связь убрана',
|
||||
contact: 'Добавлен в контакты',
|
||||
friend: 'Добавлен в друзья',
|
||||
close_friend: 'Добавлен в близкие друзья',
|
||||
};
|
||||
|
||||
// Выбор сохраняется прямо на нажатой кнопке (без строки статуса, которая сдвигала экран),
|
||||
// после сохранения – короткое сообщение и возврат на страницу пользователя.
|
||||
body.addEventListener('click', async (event) => {
|
||||
const button = event.target.closest('button');
|
||||
if (!button || busy) return;
|
||||
@@ -193,24 +208,36 @@ export function render({ route, chrome }) {
|
||||
const social = button.dataset.socialKind;
|
||||
const confirm = button.dataset.confirm;
|
||||
if (!social && !confirm) return;
|
||||
if (social && effectiveSocial(flags, 'out') === social) { navigateBack(); return; }
|
||||
|
||||
busy = true;
|
||||
body.classList.add('is-busy');
|
||||
status.className = 'status-line relation-manage-status';
|
||||
status.textContent = 'Сохранение...';
|
||||
body.querySelectorAll('button').forEach((item) => { item.disabled = true; });
|
||||
const label = button.textContent;
|
||||
button.classList.add('is-pending');
|
||||
button.textContent = 'Сохраняем…';
|
||||
|
||||
try {
|
||||
let done = '';
|
||||
if (social) {
|
||||
await changeSocial(social);
|
||||
done = SOCIAL_DONE[social] || 'Связь сохранена';
|
||||
} else if (confirm === 'official_account') {
|
||||
await setKind('official_account', !flags.outOfficialAccount);
|
||||
done = flags.outOfficialAccount ? 'Подтверждение убрано' : 'Вы подтвердили официальный аккаунт';
|
||||
} else if (confirm === 'shine_confirmed') {
|
||||
await setKind('shine_confirmed', !flags.outShineConfirmed);
|
||||
done = flags.outShineConfirmed ? 'Подтверждение убрано' : 'Вы подтвердили сияние';
|
||||
}
|
||||
await refresh({ loading: false });
|
||||
if (!screen.isConnected) return;
|
||||
showToast(done);
|
||||
navigateBack();
|
||||
} catch (error) {
|
||||
status.className = 'status-line relation-manage-status is-unavailable';
|
||||
status.textContent = `Ошибка: ${error?.message || 'Не удалось изменить связь'}`;
|
||||
if (!screen.isConnected) return;
|
||||
showToast(toUserMessage(error, 'Не удалось изменить связь'), { kind: 'error', timeoutMs: 4000 });
|
||||
button.textContent = label;
|
||||
button.classList.remove('is-pending');
|
||||
body.querySelectorAll('button').forEach((item) => { item.disabled = false; });
|
||||
} finally {
|
||||
busy = false;
|
||||
body.classList.remove('is-busy');
|
||||
|
||||
Reference in New Issue
Block a user