Обновить кошельки и мелкие детали 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
+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(); });
});
}