SHA256
Обновить кошельки и мелкие детали UI
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Экран «Связи»: люди вокруг выбранного человека – картой или списком.
|
||||
// Данные – GetUserConnectionsGraph (только чтение). Карту рисует graph-canvas.js, здесь –
|
||||
// состав (центр, раскрытые связи), фильтры, поиск, список, карточка человека и заметки.
|
||||
// состав (центр, раскрытые связи), фильтры, поиск, список, карточка человека.
|
||||
// «Компании», «Интересы» и «Города»: знакомства, подписки и города людей первого круга
|
||||
// собираются по одному запросу на человека (network/people-data-store.js), группы считает
|
||||
// network/communities.js, свои названия компаний и ручные переносы – network/companies-store.js.
|
||||
@@ -20,8 +20,6 @@ import { userDisplayName } from '../services/user-display.js';
|
||||
import { showToast } from '../services/channels-ux.js';
|
||||
import { actionErrorText, toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { matchesPeopleQuery } from '../services/people-search.js';
|
||||
import { PEOPLE_NOTES_EVENT, getAllPersonNotes } from '../services/people-notes.js';
|
||||
import { createPersonNotePreview, openPersonNoteSheet } from '../components/person-note-sheet.js';
|
||||
import { createGraphCanvas } from './network/graph-canvas.js';
|
||||
import { peopleFromGraphModel, relationTypeFromRelation } from './network/adapter.js';
|
||||
import { REST_GROUP, buildCityGroups, buildCompanies, buildInterestGroups, tieWeight } from './network/communities.js';
|
||||
@@ -194,7 +192,6 @@ const FILTERS = [
|
||||
{ id: 'close', label: 'Близкие', direct: true, pred: (node) => node.relationType === 'close_friend' || node.relationType === 'family' },
|
||||
{ id: 'friends', label: 'Друзья', direct: true, pred: (node) => node.relationType === 'friend' },
|
||||
{ id: 'shining', label: 'Сияющие', pred: (node) => Boolean(node.shining) },
|
||||
{ id: 'notes', label: 'С заметкой', pred: (node) => Boolean(node.mark || node.hasNote) },
|
||||
];
|
||||
const FILTER_BY_ID = new Map(FILTERS.map((filter) => [filter.id, filter]));
|
||||
|
||||
@@ -230,15 +227,14 @@ function tieWeights(ties, ids) {
|
||||
return weights;
|
||||
}
|
||||
|
||||
function composeMap(centerLogin, graphs, expanded, notes, ties = null) {
|
||||
function composeMap(centerLogin, graphs, expanded, ties = null) {
|
||||
const centerKey = normKey(centerLogin);
|
||||
const centerModel = graphs.get(centerKey);
|
||||
if (!centerModel) return null;
|
||||
const byId = new Map();
|
||||
const edges = [];
|
||||
const add = (node) => {
|
||||
const note = notes.get(node.id);
|
||||
byId.set(node.id, { ...node, mark: note?.mark || '', hasNote: Boolean(note?.text?.trim()), hiddenCount: 0 });
|
||||
byId.set(node.id, { ...node, hiddenCount: 0 });
|
||||
};
|
||||
|
||||
const { center, peers } = peopleFromGraphModel(centerModel);
|
||||
@@ -313,7 +309,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
let viewMode = getViewSetting('view', 'map') === 'list' ? 'list' : 'map';
|
||||
const LIST_SORTS = ['closeness', 'companies', 'interests', 'cities', 'name'];
|
||||
let listSort = LIST_SORTS.includes(getViewSetting('listSort', 'closeness')) ? getViewSetting('listSort', 'closeness') : 'closeness';
|
||||
let notes = getAllPersonNotes();
|
||||
const graphs = new Map();
|
||||
const expanding = new Set();
|
||||
let map = null;
|
||||
@@ -321,7 +316,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
let disposed = false;
|
||||
let loadSeq = 0;
|
||||
let loadError = null;
|
||||
let noteSheet = null;
|
||||
let legendSheet = null;
|
||||
let search = null; // { query, topbar, layer, remote: { seq, query, items, loading, failed } }
|
||||
let groupsModel = null; // острова «Компаний» / «Интересов»: { lens, groups, byId, byPerson }
|
||||
@@ -443,7 +437,7 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
let listFrame = 0;
|
||||
function renderMap({ fit = false, relayout = false } = {}) {
|
||||
if (disposed) return;
|
||||
map = composeMap(centerLogin, graphs, expanded, notes, getTies(normKey(centerLogin)));
|
||||
map = composeMap(centerLogin, graphs, expanded, getTies(normKey(centerLogin)));
|
||||
if (!map) return;
|
||||
// Фильтры должны быть на месте до вписывания карты: от них зависит свободная часть экрана.
|
||||
screen.classList.toggle('is-blank', map.nodes.length <= 1);
|
||||
@@ -494,7 +488,7 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
const relation = node.id === map.focusId ? 'в центре карты' : (RELATION_LABEL[node.relationType] || 'Связь').toLowerCase();
|
||||
button.textContent = `${node.name}, ${relation}${node.shining ? ', сияющий' : ''}${node.mark || node.hasNote ? ', есть заметка' : ''}`;
|
||||
button.textContent = `${node.name}, ${relation}${node.shining ? ', сияющий' : ''}`;
|
||||
button.addEventListener('click', () => selectNode(node.id, { reveal: true }));
|
||||
li.append(button);
|
||||
a11yList.append(li);
|
||||
@@ -640,7 +634,7 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
function collapseNode(id) {
|
||||
expanded.delete(id);
|
||||
for (;;) {
|
||||
const next = composeMap(centerLogin, graphs, expanded, notes);
|
||||
const next = composeMap(centerLogin, graphs, expanded);
|
||||
const orphan = [...expanded].find((key) => !next?.byId.has(key));
|
||||
if (!orphan) break;
|
||||
expanded.delete(orphan);
|
||||
@@ -809,9 +803,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
card.append(row);
|
||||
}
|
||||
|
||||
const note = isSelf ? null : notes.get(node.id);
|
||||
const notePreview = createPersonNotePreview(note, { className: 'net-card__note', onClick: () => openNoteEditor(node) });
|
||||
if (notePreview) card.append(notePreview);
|
||||
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'net-card__actions';
|
||||
@@ -829,7 +820,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
}));
|
||||
if (!isSelf) {
|
||||
actions.append(cardAction('message', 'Написать', () => navigate(`chat/${encodeURIComponent(node.login)}`)));
|
||||
actions.append(cardAction('edit', 'Заметка', () => openNoteEditor(node)));
|
||||
}
|
||||
card.append(actions);
|
||||
if (node.hiddenCount > 0) {
|
||||
@@ -842,17 +832,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
placeOverlays();
|
||||
}
|
||||
|
||||
// --- заметка ---
|
||||
function openNoteEditor(node) {
|
||||
noteSheet?.close();
|
||||
noteSheet = openPersonNoteSheet({ login: node.id, name: node.name, onClose: () => { noteSheet = null; } });
|
||||
}
|
||||
|
||||
function onNotesChanged() {
|
||||
notes = getAllPersonNotes();
|
||||
renderMap();
|
||||
}
|
||||
window.addEventListener(PEOPLE_NOTES_EVENT, onNotesChanged);
|
||||
|
||||
// --- обозначения ---
|
||||
function openLegend() {
|
||||
@@ -870,7 +849,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
['dash', 'friend', 'Пунктир → точки – вы добавили друга, ответа пока нет'],
|
||||
['aura', '', 'Свечение вокруг – сияющий'],
|
||||
['badge', '', 'Синяя галочка – официальный аккаунт'],
|
||||
['mark', '', 'Цветная точка – ваша заметка или метка'],
|
||||
];
|
||||
for (const [kind, type, text] of rows) {
|
||||
const li = document.createElement('li');
|
||||
@@ -1809,7 +1787,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
const PRIMARY_FILTERS = ['all', 'close', 'friends'];
|
||||
const EXTRA_FILTERS = [
|
||||
{ id: 'shining', short: 'Сияющие', icon: 'sparkle' },
|
||||
{ id: 'notes', short: 'С заметкой', icon: 'edit' },
|
||||
];
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'net-filters';
|
||||
@@ -2033,7 +2010,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
if (!node) return [];
|
||||
return [
|
||||
{ label: 'Профиль', iconHtml: iconHtml('profile'), action: () => navigate(profileRoute(node.login)) },
|
||||
{ label: 'Заметка', iconHtml: iconHtml('edit'), action: () => openNoteEditor(node) },
|
||||
{ label: 'Показать на карте', iconHtml: iconHtml('network'), action: () => showOnMap(node.id) },
|
||||
{ label: 'Его связи', iconHtml: iconHtml('focus'), action: () => recenter(node.login) },
|
||||
];
|
||||
@@ -2063,7 +2039,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
// Вторая строка – только то, чего не видно из раздела: тип связи нужен, когда список
|
||||
// не разбит по типам, «взаимно» – обычный случай и не пишется.
|
||||
function personRow(node, { onOpen = null, withType = false } = {}) {
|
||||
const note = notes.get(node.id);
|
||||
const sub = [];
|
||||
if (normKey(node.name) !== node.id) sub.push(node.login);
|
||||
if (node.tier > 1) {
|
||||
@@ -2082,8 +2057,6 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
avatar: node.avatar,
|
||||
official: node.official,
|
||||
sub: sub.join(' · '),
|
||||
note: note?.text?.trim() ? note.text.trim().split('\n')[0] : '',
|
||||
markColor: note?.mark || (note?.text?.trim() ? 'note' : ''),
|
||||
ring: node.shining ? 'shining' : (node.relationType === 'close_friend' && node.tier === 1 ? 'close' : ''),
|
||||
tag: '',
|
||||
onClick: onOpen || (() => {
|
||||
@@ -2326,7 +2299,7 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
|
||||
function onKeydown(event) {
|
||||
const typing = event.target instanceof HTMLElement && event.target.closest('input, textarea, [contenteditable="true"]');
|
||||
const overlayOpen = Boolean(noteSheet || legendSheet || groupSheet || document.querySelector('.dropdown-portal, .modal'));
|
||||
const overlayOpen = Boolean(legendSheet || groupSheet || document.querySelector('.dropdown-portal, .modal'));
|
||||
if (event.key === 'Escape') {
|
||||
if (overlayOpen || search) return;
|
||||
if (selectedId) selectNode('');
|
||||
@@ -2384,11 +2357,9 @@ export function render({ navigate, route, chrome } = {}) {
|
||||
moreMenu.destroy();
|
||||
window.cancelAnimationFrame(listFrame);
|
||||
window.clearTimeout(remoteTimer);
|
||||
window.removeEventListener(PEOPLE_NOTES_EVENT, onNotesChanged);
|
||||
window.removeEventListener(CONNECTIONS_GRAPH_CHANGED, refreshConnectionsView);
|
||||
window.clearInterval(graphRefreshTimer);
|
||||
document.removeEventListener('keydown', onKeydown);
|
||||
noteSheet?.close();
|
||||
legendSheet?.close();
|
||||
groupSheet?.close();
|
||||
if (search) {
|
||||
|
||||
Reference in New Issue
Block a user