SHA256
Обновить учёт поддержки, лайки и профиль перед MVP
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { getShowPublicHistoryWarning, setShowPublicHistoryWarning, getPublicHistoryRememberLabel } from '../services/public-history-consent.js';
|
||||
import { confirmPublicHistoryAction } from '../services/public-history-consent.js';
|
||||
import { openSheet } from './sheet.js';
|
||||
import { iconHtml } from './ui-icon.js';
|
||||
|
||||
function safeCount(raw, maximum = Infinity) {
|
||||
const count = Number(raw);
|
||||
@@ -9,7 +10,6 @@ function safeCount(raw, maximum = Infinity) {
|
||||
|
||||
// Значения счётчиков получены от сервера, это не криптографическая аттестация личности.
|
||||
export function confirmLikeAction(options = {}) {
|
||||
if (!getShowPublicHistoryWarning()) return Promise.resolve(true);
|
||||
return openLikeSheet(options);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export function showLikeStatistics({ counts = {}, onViewList = null } = {}) {
|
||||
function openLikeSheet({ liked = false, counts = {}, onViewList = null, readOnly = false } = {}) {
|
||||
return new Promise((resolve) => {
|
||||
let accepted = false;
|
||||
let confirming = false;
|
||||
const all = safeCount(counts.all ?? counts.likesCount);
|
||||
const official = safeCount(counts.official ?? counts.primaryLikesCount, all);
|
||||
const shining = safeCount(counts.shining ?? counts.shiningLikesCount, official);
|
||||
@@ -49,19 +50,16 @@ function openLikeSheet({ liked = false, counts = {}, onViewList = null, readOnly
|
||||
number.textContent = String(count);
|
||||
const name = document.createElement('span');
|
||||
name.textContent = label;
|
||||
item.append(number, name);
|
||||
const heart = document.createElement('span');
|
||||
heart.className = 'like-consent-heart';
|
||||
heart.innerHTML = iconHtml('heart', true);
|
||||
heart.setAttribute('aria-hidden', 'true');
|
||||
item.append(heart, number, name);
|
||||
grid.append(item);
|
||||
});
|
||||
const warning = document.createElement('p');
|
||||
warning.className = 'meta-muted';
|
||||
warning.textContent = t('dialogs.modals.like_action_sheet.label_002');
|
||||
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 = getPublicHistoryRememberLabel();
|
||||
rememberLabel.append(remember, rememberText);
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'form-actions-grid';
|
||||
const cancel = document.createElement('button');
|
||||
@@ -75,10 +73,14 @@ function openLikeSheet({ liked = false, counts = {}, onViewList = null, readOnly
|
||||
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: t('dialogs.modals.like_action_sheet.label_005'), className: 'like-consent-sheet', content: body, onClose: () => resolve(accepted) });
|
||||
const sheet = openSheet({ title: t('dialogs.modals.like_action_sheet.label_005'), className: 'like-consent-sheet', content: body, onClose: () => { if (!confirming) resolve(accepted); } });
|
||||
cancel.addEventListener('click', () => sheet.close());
|
||||
confirm.addEventListener('click', () => { if (remember.checked) setShowPublicHistoryWarning(false); accepted = true; sheet.close(); });
|
||||
confirm.addEventListener('click', async () => {
|
||||
confirming = true;
|
||||
sheet.close();
|
||||
accepted = await confirmPublicHistoryAction({ text: warning.textContent });
|
||||
resolve(accepted);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
||||
<span class="pf-row-label">${th('screens.profile_card.text_019')}</span>
|
||||
<p class="pf-row-text">${esc(spiritualPath)}</p>
|
||||
</div>` : '';
|
||||
const listInner = aboutRow + contacts + pathRow;
|
||||
const detailButtons = (contacts || pathRow) ? `<div class="pf-detail-actions">${contacts ? `<button type="button" class="ui-button" data-profile-detail="contacts">${th('screens.profile_card.text_008')}</button>` : ''}${pathRow ? `<button type="button" class="ui-button" data-profile-detail="path">${th('screens.profile_card.text_019')}</button>` : ''}</div>` : '';
|
||||
const listInner = aboutRow + detailButtons + (contacts ? `<div class="pf-detail-panel" data-profile-panel="contacts" hidden>${contacts}</div>` : '') + (pathRow ? `<div class="pf-detail-panel" data-profile-panel="path" hidden>${pathRow}</div>` : '');
|
||||
const listHtml = listInner.trim() ? `<div class="pf-list">${listInner}</div>` : '';
|
||||
const friends = Number(stats.friendsCount || 0);
|
||||
const closeFriends = Number(stats.closeFriendsCount || 0);
|
||||
@@ -115,7 +116,7 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
||||
<span class="pf-stat-relation"><strong class="pf-stat-value">${closeFriends}</strong><span class="pf-stat-label">${esc(t('remaining.share.close_friends'))}</span></span>
|
||||
<span class="pf-stat-relation"><strong class="pf-stat-value">${friends}</strong><span class="pf-stat-label">${esc(t('screens.profile_card.text_003'))}</span></span>
|
||||
</button>
|
||||
${statHtml({ kind: 'channels_owned', label: t('screens.profile_card.text_004'), valueHtml: String(Number(stats.ownedPublicChannelsCount || 0)), ariaLabel: t('screens.profile_card.text_015', { value1: Number(stats.ownedPublicChannelsCount || 0) }) })}
|
||||
${statHtml({ kind: 'channels_owned', label: t('screens.profile_card.text_004'), valueHtml: String(Math.max(0, Number(stats.ownedPublicChannelsCount || 0) - 1)), ariaLabel: t('screens.profile_card.text_015', { value1: Math.max(0, Number(stats.ownedPublicChannelsCount || 0) - 1) }) })}
|
||||
${statHtml({ kind: 'channels_following', label: t('screens.profile_card.text_005'), valueHtml: String(Number(stats.followingChannelsCount || 0)), ariaLabel: t('screens.profile_card.text_016', { value1: Number(stats.followingChannelsCount || 0) }) })}
|
||||
</div>
|
||||
|
||||
@@ -128,6 +129,19 @@ export function profileCardHtml({ card, login = '', tilesHtml = '', tilesWrapCla
|
||||
${listHtml}`;
|
||||
}
|
||||
|
||||
export function attachProfileDetails(root) {
|
||||
root.querySelectorAll('[data-profile-detail]').forEach((button) => {
|
||||
button.addEventListener('click', async () => {
|
||||
const panel = root.querySelector(`[data-profile-panel="${button.dataset.profileDetail}"]`);
|
||||
if (!panel) return;
|
||||
const { openSheet } = await import('./sheet.js');
|
||||
const content = panel.cloneNode(true);
|
||||
content.hidden = false;
|
||||
openSheet({ title: button.textContent.trim(), content });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function profileTileHtml({ icon, label, attrs = '', iconMarkup = '' }) {
|
||||
return `<button type="button" class="pf-tile user-profile-action-btn" ${attrs}>${iconMarkup || iconHtml(icon)}<span>${esc(label)}</span></button>`;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { readShineUserPda, supportShineUserOnSolana, supportShineDaoOnSolana } f
|
||||
import { loadEncryptedUserSecrets } from '../services/key-vault.js';
|
||||
import { getWalletFromStoredBlockchainKey, transferSolLamports, solanaAddressFromPublicKeyBase64 } from '../services/solana-wallet-service.js';
|
||||
import { bytesToBase58 } from '../services/crypto-utils.js';
|
||||
import { parseStarCents, formatStars, splitStarCents, starCentsToLamports, formatLamportsSol } from '../services/shine-support-amount.js';
|
||||
import { parseStarCents, formatStars, formatExactStars, splitStarCents, starCentsToLamports, formatLamportsSol } from '../services/shine-support-amount.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import { getStarsQuoteFromRpc } from '../services/shine-stars-pyth.js';
|
||||
|
||||
@@ -34,7 +34,7 @@ export function openShineSupportDialog({ recipientLogin = '', target = { type: 0
|
||||
input.type = 'text';
|
||||
input.inputMode = 'decimal';
|
||||
input.autocomplete = 'off';
|
||||
input.placeholder = '0.10';
|
||||
input.placeholder = '0.1';
|
||||
const details = document.createElement('p');
|
||||
details.className = 'meta-muted';
|
||||
const status = document.createElement('p');
|
||||
@@ -69,8 +69,8 @@ export function openShineSupportDialog({ recipientLogin = '', target = { type: 0
|
||||
const split = splitStarCents(cents);
|
||||
const sol = quote ? ` · ≈ ${formatLamportsSol(starCentsToLamports(cents, quote.solUsdE8, quote.usdtUsdE8))} SOL` : '';
|
||||
details.textContent = dao ? `${formatStars(cents)}${sol}` :
|
||||
`${t('screens.support_phase2.recipient')}: ${formatStars(split.author)} · ${t('screens.support_phase2.fund')}: ${formatStars(split.dao)}${sol}`;
|
||||
} catch { details.textContent = 'Минимум 0,10 ⭐'; }
|
||||
`${t('screens.support_phase2.recipient')}: ${formatExactStars(split.author)} · ${t('screens.support_phase2.fund')}: ${formatExactStars(split.dao)}${sol}`;
|
||||
} catch { details.textContent = 'Минимум 0,1 ⭐'; }
|
||||
};
|
||||
input.addEventListener('input', update);
|
||||
amountLabel.textContent = 'Сумма поддержки, ⭐';
|
||||
|
||||
@@ -51,10 +51,10 @@ function renderAmount(cents, sign = '') {
|
||||
value.className = 'profile-support-amount__value';
|
||||
value.setAttribute('aria-hidden', 'true');
|
||||
value.dataset.cents = String(cents);
|
||||
value.textContent = `${sign}${formatStarAmount(cents)}`;
|
||||
value.textContent = formatStarAmount(cents) ? `${sign}${formatStarAmount(cents)}` : '';
|
||||
const spoken = document.createElement('span');
|
||||
spoken.className = 'sr-only';
|
||||
spoken.textContent = `${sign}${formatStars(cents)}`;
|
||||
spoken.textContent = formatStarAmount(cents) ? `${sign}${formatStars(cents)}` : '⭐';
|
||||
wrap.append(value);
|
||||
wrap.insertAdjacentHTML('beforeend', iconHtml('star', true, 'profile-support-amount__star'));
|
||||
wrap.append(spoken);
|
||||
|
||||
Reference in New Issue
Block a user