Обновить кошельки и мелкие детали UI

This commit is contained in:
AidarKC
2026-11-09 09:59:11 +03:00
parent 34f7faf0a8
commit 526941eb33
29 changed files with 469 additions and 201 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
import { iconHtml } from './ui-icon.js';
import { confirmDialog } from './confirm-dialog.js';
import { confirmPublicHistoryAction } from '../services/public-history-consent.js';
import { markArweaveAttachmentPlaced } from './arweave-attachment-manager.js';
import { openChannelAttachmentManager } from './channel-attachment-manager.js';
import { composeMessageWithAttachments, MAX_MESSAGE_ATTACHMENTS } from '../services/attachment-format.js';
@@ -340,7 +340,7 @@ export function openChannelEditor({
submitButton.textContent = 'Отправляем…';
sync();
try {
const accepted = await confirmDialog({
const accepted = await confirmPublicHistoryAction({
title: 'Записать в публичную историю?',
aboveEditor: true,
text: 'Эта публикация, ответ или изменение будут записаны в блокчейн. Запись может сохраняться постоянно, включая историю правок и удаления. Если передумали, выберите «Вернуться к черновику».',
+13
View File
@@ -6,6 +6,7 @@ export function confirmDialog({
cancelLabel = 'Отмена',
danger = false,
aboveEditor = false,
rememberChoice = null,
} = {}) {
return new Promise((resolve) => {
const opener = document.activeElement;
@@ -25,6 +26,17 @@ export function confirmDialog({
const textEl = modal.querySelector('.confirm-dialog__text');
textEl.textContent = text;
textEl.hidden = !text;
let rememberCheckbox = null;
if (rememberChoice?.label) {
const label = document.createElement('label');
label.className = 'confirm-dialog__remember';
rememberCheckbox = document.createElement('input');
rememberCheckbox.type = 'checkbox';
const explanation = document.createElement('span');
explanation.textContent = rememberChoice.label;
label.append(rememberCheckbox, explanation);
modal.querySelector('.form-actions-grid').before(label);
}
modal.querySelector('[data-answer="no"]').textContent = cancelLabel;
modal.querySelector('[data-answer="yes"]').textContent = confirmLabel;
@@ -32,6 +44,7 @@ export function confirmDialog({
document.removeEventListener('keydown', onKeydown, true);
modal.remove();
opener?.focus?.();
if (answer && rememberCheckbox?.checked) rememberChoice?.onConfirm?.();
resolve(answer);
};
const onKeydown = (event) => {
+26 -5
View File
@@ -1,3 +1,4 @@
import { getShowPublicHistoryWarning, setShowPublicHistoryWarning, PUBLIC_HISTORY_REMEMBER_LABEL } from '../services/public-history-consent.js';
import { openSheet } from './sheet.js';
function safeCount(raw, maximum = Infinity) {
@@ -6,7 +7,17 @@ function safeCount(raw, maximum = Infinity) {
}
// Значения счётчиков получены от сервера, это не криптографическая аттестация личности.
export function confirmLikeAction({ liked = false, counts = {}, onViewList = null } = {}) {
export function confirmLikeAction(options = {}) {
if (!getShowPublicHistoryWarning()) return Promise.resolve(true);
return openLikeSheet(options);
}
// Просмотр счётчиков не является действием в блокчейне и не спрашивает согласие.
export function showLikeStatistics({ counts = {}, onViewList = null } = {}) {
return openLikeSheet({ counts, onViewList, readOnly: true });
}
function openLikeSheet({ liked = false, counts = {}, onViewList = null, readOnly = false } = {}) {
return new Promise((resolve) => {
let accepted = false;
const all = safeCount(counts.all ?? counts.likesCount);
@@ -43,20 +54,30 @@ export function confirmLikeAction({ liked = false, counts = {}, onViewList = nul
const warning = document.createElement('p');
warning.className = 'meta-muted';
warning.textContent = 'Добавление и отмена лайка создают записи в публичной истории блокчейна. Даже отменённый лайк может остаться в истории.';
const rememberLabel = document.createElement('label');
rememberLabel.className = 'confirm-dialog__remember';
const remember = document.createElement('input');
remember.type = 'checkbox';
const rememberText = document.createElement('span');
rememberText.textContent = PUBLIC_HISTORY_REMEMBER_LABEL;
rememberLabel.append(remember, rememberText);
const actions = document.createElement('div');
actions.className = 'form-actions-grid';
const cancel = document.createElement('button');
cancel.type = 'button';
cancel.className = 'secondary-btn';
cancel.textContent = 'Не менять';
cancel.textContent = readOnly ? 'Закрыть' : 'Не менять';
const confirm = document.createElement('button');
confirm.type = 'button';
confirm.className = 'primary-btn';
confirm.textContent = liked ? 'Убрать мой лайк' : 'Добавить мой лайк';
actions.append(cancel, confirm);
body.append(intro, grid, warning, actions);
if (readOnly) actions.append(cancel);
else actions.append(cancel, confirm);
body.append(intro, grid);
if (!readOnly) body.append(warning, rememberLabel);
body.append(actions);
const sheet = openSheet({ title: 'Лайки', className: 'like-consent-sheet', content: body, onClose: () => resolve(accepted) });
cancel.addEventListener('click', () => sheet.close());
confirm.addEventListener('click', () => { accepted = true; sheet.close(); });
confirm.addEventListener('click', () => { if (remember.checked) setShowPublicHistoryWarning(false); accepted = true; sheet.close(); });
});
}
@@ -0,0 +1,29 @@
import { iconHtml } from './ui-icon.js';
/** The password is intentionally visible initially on both auth screens. */
export function createVisiblePasswordField(input) {
input.type = 'text';
const wrap = document.createElement('div');
wrap.className = 'auth-password-field';
const toggle = document.createElement('button');
toggle.type = 'button';
toggle.className = 'auth-password-field__toggle';
function updateToggle() {
const visible = input.type !== 'password';
toggle.innerHTML = iconHtml(visible ? 'eyeOff' : 'eye', false, 'key-toggle-icon');
toggle.setAttribute('aria-label', visible ? 'Скрыть пароль' : 'Показать пароль');
toggle.setAttribute('title', visible ? 'Скрыть пароль' : 'Показать пароль');
toggle.setAttribute('aria-pressed', String(!visible));
}
toggle.addEventListener('click', () => {
const start = input.selectionStart;
const end = input.selectionEnd;
input.type = input.type === 'password' ? 'text' : 'password';
updateToggle();
input.focus();
try { if (start !== null && end !== null) input.setSelectionRange(start, end); } catch { /* unsupported input method */ }
});
updateToggle();
wrap.append(input, toggle);
return wrap;
}