SHA256
Личные сообщения: - поиск по переписке с подсветкой, переход к дате по календарю; - экран «Медиа и файлы» (/chat/<login>/media); - «без звука» и закрепление чатов (на устройстве), push от заглушённых не показывается; - новая нижняя панель ввода, круглый спиннер истории, медиа-карусель; - история загружается в ~16 раз быстрее: ключ расшифровки достаётся один раз на страницу; - исправлены прозрачные окна подтверждения в чате. Связи: - карта переписана на canvas (graph-canvas.js вместо force-graph.js): плавная анимация без дёрганья, панорама, масштаб щипком/колесом/кнопками, перетаскивание людей; - ручная раскладка и режимы «По близости»/«По группам» запоминаются на устройстве; - цвет нити – тип связи, пунктир – связь с одной стороны, аура только у сияющих; - карточка человека: раскрыть связи на месте, в центр, профиль, написать, заметка; - «Недавние» заменены раскрытием связей; фильтр «Заметки». Личные заметки о людях (текст и цветная метка, только на устройстве) – на карте и в профиле.
92 lines
4.2 KiB
JavaScript
92 lines
4.2 KiB
JavaScript
// Шторка «Заметка о человеке»: текст и цветная метка, видны только владельцу аккаунта.
|
||
// Открывается с карты связей и из профиля человека; хранение – services/people-notes.js.
|
||
import { openSheet } from './sheet.js';
|
||
import { NOTE_MARKS, PERSON_NOTE_MAX_TEXT, getPersonNote, setPersonNote } from '../services/people-notes.js';
|
||
|
||
export function openPersonNoteSheet({ login, name = '', onClose = null } = {}) {
|
||
const current = getPersonNote(login);
|
||
let mark = current?.mark || '';
|
||
return openSheet({
|
||
title: `Заметка: ${name || login}`,
|
||
className: 'person-note-sheet',
|
||
onClose,
|
||
content: (sheet) => {
|
||
const wrap = document.createElement('div');
|
||
wrap.className = 'stack person-note';
|
||
const hint = document.createElement('p');
|
||
hint.className = 'meta-muted person-note__hint';
|
||
hint.textContent = 'Видна только вам. Пока хранится на этом устройстве.';
|
||
const textarea = document.createElement('textarea');
|
||
textarea.className = 'input person-note__text';
|
||
textarea.rows = 5;
|
||
textarea.maxLength = PERSON_NOTE_MAX_TEXT;
|
||
textarea.placeholder = 'Кто это, откуда знакомы, о чём договорились…';
|
||
textarea.value = current?.text || '';
|
||
textarea.setAttribute('aria-label', 'Текст заметки');
|
||
textarea.autofocus = true;
|
||
|
||
const marksLabel = document.createElement('div');
|
||
marksLabel.className = 'person-note__label';
|
||
marksLabel.id = `person-note-marks-${Math.random().toString(36).slice(2, 8)}`;
|
||
marksLabel.textContent = 'Метка на карте связей';
|
||
const marks = document.createElement('div');
|
||
marks.className = 'person-note__marks';
|
||
marks.setAttribute('role', 'radiogroup');
|
||
marks.setAttribute('aria-labelledby', marksLabel.id);
|
||
const markButtons = [];
|
||
const syncMarks = () => markButtons.forEach((button) => button.setAttribute('aria-checked', String(button.dataset.mark === mark)));
|
||
for (const option of [{ id: '', label: 'Без метки' }, ...NOTE_MARKS]) {
|
||
const button = document.createElement('button');
|
||
button.type = 'button';
|
||
button.className = 'person-note__mark';
|
||
button.dataset.mark = option.id;
|
||
button.setAttribute('role', 'radio');
|
||
button.setAttribute('aria-label', option.label);
|
||
button.title = option.label;
|
||
button.addEventListener('click', () => { mark = option.id; syncMarks(); });
|
||
markButtons.push(button);
|
||
marks.append(button);
|
||
}
|
||
syncMarks();
|
||
wrap.append(hint, textarea, marksLabel, marks);
|
||
|
||
if (current) {
|
||
const remove = document.createElement('button');
|
||
remove.type = 'button';
|
||
remove.className = 'ghost-btn person-note__remove';
|
||
remove.textContent = 'Удалить';
|
||
remove.addEventListener('click', () => {
|
||
setPersonNote(login, { text: '', mark: '' });
|
||
sheet.close();
|
||
});
|
||
sheet.footer.append(remove);
|
||
}
|
||
const save = document.createElement('button');
|
||
save.type = 'button';
|
||
save.className = 'primary-btn person-note__save';
|
||
save.textContent = 'Сохранить';
|
||
save.addEventListener('click', () => {
|
||
setPersonNote(login, { text: textarea.value, mark });
|
||
sheet.close();
|
||
});
|
||
sheet.footer.append(save);
|
||
return wrap;
|
||
},
|
||
});
|
||
}
|
||
|
||
// Готовый блок заметки (для карточки на карте и профиля); null, если заметки нет.
|
||
export function createPersonNotePreview(note, { className = '', onClick = null } = {}) {
|
||
if (!note) return null;
|
||
const el = document.createElement(onClick ? 'button' : 'div');
|
||
if (onClick) {
|
||
el.type = 'button';
|
||
el.title = 'Изменить заметку';
|
||
el.addEventListener('click', onClick);
|
||
}
|
||
el.className = `person-note-preview${className ? ` ${className}` : ''}`;
|
||
if (note.mark) el.dataset.mark = note.mark;
|
||
el.textContent = note.text.trim() || 'Метка без текста';
|
||
return el;
|
||
}
|