SHA256
UI: запоминать Arweave-кошелёк загрузчика
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.4.18
|
client.version=1.4.19
|
||||||
server.version=1.4.5
|
server.version=1.4.5
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { addArweaveWalletSecret, getArweaveBalance, getArweaveWalletChoices } fr
|
|||||||
import { escapeHtml, formatBytes, normalizeAttachment } from '../services/attachment-format.js';
|
import { escapeHtml, formatBytes, normalizeAttachment } from '../services/attachment-format.js';
|
||||||
|
|
||||||
const HISTORY_KEY = 'shine-ui-arweave-attachment-history-v1';
|
const HISTORY_KEY = 'shine-ui-arweave-attachment-history-v1';
|
||||||
|
const LAST_WALLET_KEY_PREFIX = 'shine-ui-arweave-last-wallet-v1:';
|
||||||
const MAX_HISTORY_ITEMS = 100;
|
const MAX_HISTORY_ITEMS = 100;
|
||||||
const RECENT_UPLOAD_MS = 20 * 60 * 1000;
|
const RECENT_UPLOAD_MS = 20 * 60 * 1000;
|
||||||
|
|
||||||
@@ -135,6 +136,27 @@ function shortAddress(value) {
|
|||||||
return `${raw.slice(0, 8)}...${raw.slice(-6)}`;
|
return `${raw.slice(0, 8)}...${raw.slice(-6)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lastWalletStorageKey(login) {
|
||||||
|
return `${LAST_WALLET_KEY_PREFIX}${String(login || '').trim().toLowerCase() || 'anonymous'}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readLastWalletId(login) {
|
||||||
|
try {
|
||||||
|
return sessionStorage.getItem(lastWalletStorageKey(login)) || '';
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeLastWalletId(login, walletId) {
|
||||||
|
try {
|
||||||
|
const clean = String(walletId || '').trim();
|
||||||
|
if (clean) sessionStorage.setItem(lastWalletStorageKey(login), clean);
|
||||||
|
} catch {
|
||||||
|
// Если sessionStorage недоступен, выбор сохраняется хотя бы в текущем окне менеджера.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function resizeImageFileToAvatar(file) {
|
async function resizeImageFileToAvatar(file) {
|
||||||
const source = file instanceof File ? file : null;
|
const source = file instanceof File ? file : null;
|
||||||
if (!source) throw new Error('Выберите изображение.');
|
if (!source) throw new Error('Выберите изображение.');
|
||||||
@@ -186,7 +208,7 @@ export function openArweaveAttachmentManager({
|
|||||||
|
|
||||||
let closed = false;
|
let closed = false;
|
||||||
let wallets = [];
|
let wallets = [];
|
||||||
let selectedWalletId = 'derived-client-key';
|
let selectedWalletId = readLastWalletId(cleanLogin) || 'derived-client-key';
|
||||||
let selectedFile = null;
|
let selectedFile = null;
|
||||||
let selectedSha256 = '';
|
let selectedSha256 = '';
|
||||||
let priceInfo = null;
|
let priceInfo = null;
|
||||||
@@ -235,6 +257,7 @@ export function openArweaveAttachmentManager({
|
|||||||
if (!wallets.some((item) => String(item.id) === String(selectedWalletId))) {
|
if (!wallets.some((item) => String(item.id) === String(selectedWalletId))) {
|
||||||
selectedWalletId = String(wallets[0]?.id || 'derived-client-key');
|
selectedWalletId = String(wallets[0]?.id || 'derived-client-key');
|
||||||
}
|
}
|
||||||
|
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setText(errorEl, error?.message || 'Не удалось загрузить Arweave-кошельки.');
|
setText(errorEl, error?.message || 'Не удалось загрузить Arweave-кошельки.');
|
||||||
}
|
}
|
||||||
@@ -246,7 +269,7 @@ export function openArweaveAttachmentManager({
|
|||||||
<div class="modal-card stack ar-attachment-manager-card">
|
<div class="modal-card stack ar-attachment-manager-card">
|
||||||
<h3 class="modal-title">${isAvatarMode ? 'Загрузить аватар' : (historyOnly ? 'Загрузить файл в блокчейн' : 'Добавить вложение')}</h3>
|
<h3 class="modal-title">${isAvatarMode ? 'Загрузить аватар' : (historyOnly ? 'Загрузить файл в блокчейн' : 'Добавить вложение')}</h3>
|
||||||
<label class="meta-muted" for="ar-attach-wallet">Кошелёк оплаты Arweave</label>
|
<label class="meta-muted" for="ar-attach-wallet">Кошелёк оплаты Arweave</label>
|
||||||
<select class="input" id="ar-attach-wallet"></select>
|
<select class="input ar-attachment-wallet-select" id="ar-attach-wallet"></select>
|
||||||
<button class="ghost-btn" type="button" data-action="add-wallet">Добавить кошелёк</button>
|
<button class="ghost-btn" type="button" data-action="add-wallet">Добавить кошелёк</button>
|
||||||
${isAvatarMode ? '<p class="meta-muted">Выберите изображение. Перед загрузкой оно будет сжато до 512×512 и сохранено в истории как аватар.</p>' : (historyOnly ? '' : '<p class="meta-muted">Для надёжности лучше сначала загрузить файл в Arweave, дождаться доступности в журнале, а потом добавить его из истории загрузок.</p>')}
|
${isAvatarMode ? '<p class="meta-muted">Выберите изображение. Перед загрузкой оно будет сжато до 512×512 и сохранено в истории как аватар.</p>' : (historyOnly ? '' : '<p class="meta-muted">Для надёжности лучше сначала загрузить файл в Arweave, дождаться доступности в журнале, а потом добавить его из истории загрузок.</p>')}
|
||||||
<label class="meta-muted" for="ar-attach-file">Файл для загрузки</label>
|
<label class="meta-muted" for="ar-attach-file">Файл для загрузки</label>
|
||||||
@@ -275,6 +298,7 @@ export function openArweaveAttachmentManager({
|
|||||||
walletEl.value = selectedWalletId;
|
walletEl.value = selectedWalletId;
|
||||||
walletEl.addEventListener('change', () => {
|
walletEl.addEventListener('change', () => {
|
||||||
selectedWalletId = String(walletEl.value || '');
|
selectedWalletId = String(walletEl.value || '');
|
||||||
|
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||||
uploadBtn.disabled = true;
|
uploadBtn.disabled = true;
|
||||||
selectedFile = null;
|
selectedFile = null;
|
||||||
selectedSha256 = '';
|
selectedSha256 = '';
|
||||||
@@ -535,6 +559,7 @@ export function openArweaveAttachmentManager({
|
|||||||
secret: String(secretEl?.value || '').trim(),
|
secret: String(secretEl?.value || '').trim(),
|
||||||
});
|
});
|
||||||
selectedWalletId = wallet.id;
|
selectedWalletId = wallet.id;
|
||||||
|
writeLastWalletId(cleanLogin, selectedWalletId);
|
||||||
await showUpload();
|
await showUpload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
saveBtn.disabled = false;
|
saveBtn.disabled = false;
|
||||||
|
|||||||
@@ -2485,6 +2485,11 @@ textarea.input {
|
|||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ar-attachment-wallet-select,
|
||||||
|
.ar-attachment-wallet-select option {
|
||||||
|
color: #38bdf8;
|
||||||
|
}
|
||||||
|
|
||||||
.ar-attachment-history-table-wrap {
|
.ar-attachment-history-table-wrap {
|
||||||
max-height: 55vh;
|
max-height: 55vh;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user