SHA256
Чужой профиль: видно, кем человек вам приходится
- плитка «Добавить связь» показывает текущую связь («Друг ✓», «Близкий друг ✓», «Контакт ✓») или предлагает ответить – «Дружить в ответ» / «Добавить в ответ» с подписью «… хочет с вами дружить» / «… добавил(а) вас в контакты»; - загрузка – спиннер с задержкой вместо «Загрузка профиля...», ошибка – понятным текстом и «Повторить».
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@
|
||||
}());
|
||||
</script>
|
||||
<script>
|
||||
window.__SHINE_BUILD_HASH__ = '20261013070000';
|
||||
window.__SHINE_BUILD_HASH__ = '20261013073000';
|
||||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||||
</script>
|
||||
<script>
|
||||
|
||||
@@ -2,7 +2,9 @@ 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 { loadRelationsForPair, loadUserProfileCard } from '../services/user-connections.js';
|
||||
import { createErrorState, createLoadingState } from '../components/feedback.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { makeProfileLinksRoute } from '../services/shine-routes.js';
|
||||
import { navigateBack } from '../router.js';
|
||||
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
|
||||
@@ -35,8 +37,8 @@ export function render({ navigate, route, chrome }) {
|
||||
chrome?.setTopbar(header);
|
||||
|
||||
const status = document.createElement('div');
|
||||
status.className = 'status-line user-profile-status';
|
||||
status.textContent = 'Загрузка профиля...';
|
||||
status.className = 'user-profile-status';
|
||||
status.append(createLoadingState({ label: 'Загружаю профиль' }));
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'user-profile-body';
|
||||
@@ -45,6 +47,7 @@ export function render({ navigate, route, chrome }) {
|
||||
let card = null;
|
||||
let disposed = false;
|
||||
let noteSheet = null;
|
||||
let relation = null; // кем человек вам приходится – для плитки «Добавить связь»
|
||||
|
||||
function openNote() {
|
||||
noteSheet?.close();
|
||||
@@ -80,6 +83,7 @@ export function render({ navigate, route, chrome }) {
|
||||
noteEl.addEventListener('click', openNote);
|
||||
}
|
||||
if (noteEl) body.querySelector('.pf-tiles-wrap')?.after(noteEl);
|
||||
syncRelationTile();
|
||||
|
||||
const avatarSlot = body.querySelector('.user-profile-avatar-slot');
|
||||
avatarSlot?.append(renderUserAvatar({
|
||||
@@ -92,7 +96,35 @@ export function render({ navigate, route, chrome }) {
|
||||
official: card.accountRole === 'primary',
|
||||
}));
|
||||
|
||||
status.textContent = '';
|
||||
status.replaceChildren();
|
||||
}
|
||||
|
||||
// Плитка показывает текущую связь («Друг ✓») или предлагает ответить, если человек
|
||||
// добавил вас первым; нажатие – как раньше, в управление связью.
|
||||
function syncRelationTile() {
|
||||
const tile = body.querySelector('[data-profile-action="add"]');
|
||||
if (!tile || !relation) return;
|
||||
const r = relation;
|
||||
const theyFriend = r.inFriend || r.inCloseFriend;
|
||||
let icon = 'user-plus';
|
||||
let label = 'Добавить связь';
|
||||
let hint = '';
|
||||
if (r.outCloseFriend) { icon = 'check'; label = 'Близкий друг'; }
|
||||
else if (r.outFriend) { icon = 'check'; label = 'Друг'; }
|
||||
else if (r.outContact) { icon = 'check'; label = 'Контакт'; }
|
||||
else if (theyFriend) { label = 'Дружить в ответ'; hint = 'хочет с вами дружить'; }
|
||||
else if (r.inContact) { label = 'Добавить в ответ'; hint = 'добавил(а) вас в контакты'; }
|
||||
tile.innerHTML = `${iconHtml(icon)}<span></span>`;
|
||||
tile.querySelector('span').textContent = label;
|
||||
tile.classList.toggle('is-related', icon === 'check');
|
||||
tile.setAttribute('aria-label', icon === 'check' ? `${label}. Изменить связь` : label);
|
||||
body.querySelector('.user-profile-relation-hint')?.remove();
|
||||
if (hint) {
|
||||
const note = document.createElement('p');
|
||||
note.className = 'user-profile-relation-hint';
|
||||
note.textContent = `${[card.firstName, card.lastName].map((v) => String(v || '').trim()).filter(Boolean).join(' ') || card.login} ${hint}`;
|
||||
body.querySelector('.pf-tiles-wrap')?.before(note);
|
||||
}
|
||||
}
|
||||
|
||||
body.addEventListener('click', (event) => {
|
||||
@@ -133,13 +165,29 @@ export function render({ navigate, route, chrome }) {
|
||||
if (disposed) return;
|
||||
card = loaded;
|
||||
renderProfile();
|
||||
if (selfLogin && card.login.toLowerCase() !== selfLogin.toLowerCase()) {
|
||||
loadRelationsForPair({ currentLogin: selfLogin, targetLogin: card.login })
|
||||
.then((flags) => {
|
||||
if (disposed) return;
|
||||
relation = flags;
|
||||
syncRelationTile();
|
||||
})
|
||||
.catch(() => { /* без сведений о связи плитка остаётся «Добавить связь» */ });
|
||||
}
|
||||
}
|
||||
|
||||
refresh().catch((error) => {
|
||||
const showLoadError = (error) => {
|
||||
if (disposed) return;
|
||||
status.className = 'status-line user-profile-status is-unavailable';
|
||||
status.textContent = `Ошибка: ${error?.message || 'unknown'}`;
|
||||
});
|
||||
status.replaceChildren(createErrorState({
|
||||
title: 'Не удалось загрузить профиль',
|
||||
text: toUserMessage(error, 'Проверьте соединение и попробуйте ещё раз.'),
|
||||
onRetry: () => {
|
||||
status.replaceChildren(createLoadingState({ label: 'Загружаю профиль', delayMs: 0 }));
|
||||
refresh().catch(showLoadError);
|
||||
},
|
||||
}));
|
||||
};
|
||||
refresh().catch(showLoadError);
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
@@ -175,3 +175,7 @@
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
/* Чужой профиль: плитка связи показывает текущую связь, над плитками – «хочет с вами дружить». */
|
||||
.pf-tile.is-related svg { color: var(--success); }
|
||||
.user-profile-relation-hint { margin: 0 0 var(--space-2); color: var(--accent); font-size: var(--text-sm); font-weight: var(--weight-medium); text-align: center; }
|
||||
|
||||
Reference in New Issue
Block a user