fix(clipboard): copy toasts reflect the configured clear delay
The "clears in 30s" suffix was hardcoded in ~14 toasts. Single helper
clipClearSuffix() reads clipboardClearSeconds (''=Never); prefixes concatenated
to it. Cheatsheet text made generic "(auto-clears)".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1106,6 +1106,13 @@ function toast(msg, type) {
|
||||
|
||||
function $(sel, root) { return (root || document).querySelector(sel); }
|
||||
function $$(sel, root) { return Array.from((root || document).querySelectorAll(sel)); }
|
||||
// Toast suffix for a just-copied secret, honouring the auto-clear setting.
|
||||
// '' when the user disabled auto-clear (Never).
|
||||
function clipClearSuffix() {
|
||||
const s = state.clipboardClearSeconds;
|
||||
return s > 0 ? ' · clears in ' + s + 's' : '';
|
||||
}
|
||||
|
||||
function el(tag, props, ...kids) {
|
||||
const e = document.createElement(tag);
|
||||
if (props) for (const k in props) {
|
||||
@@ -4205,7 +4212,7 @@ function buildCustomFieldRow(field, idx, rerender) {
|
||||
if (!v) return;
|
||||
if (Bridge.active) Bridge.copySecure(v, 30000);
|
||||
else { try { navigator.clipboard.writeText(v); } catch (_) {} }
|
||||
toast('Copied · clears in 30s');
|
||||
toast('Copied' + clipClearSuffix());
|
||||
});
|
||||
|
||||
const delBtn = el('button', { class: 'icon-btn icon-btn-sm', type: 'button',
|
||||
@@ -4366,10 +4373,10 @@ function soPasswordField(plain) {
|
||||
copy.appendChild(icon('i-copy'));
|
||||
copy.addEventListener('click', () => {
|
||||
if (Bridge.copySecure(input.value, 30000)) {
|
||||
toast('Copied · clears in 30s');
|
||||
toast('Copied' + clipClearSuffix());
|
||||
} else {
|
||||
navigator.clipboard.writeText(input.value).then(() => {
|
||||
toast('Copied · clears in 30s');
|
||||
toast('Copied' + clipClearSuffix());
|
||||
setTimeout(() => navigator.clipboard.writeText('').catch(()=>{}), 30000);
|
||||
});
|
||||
}
|
||||
@@ -4497,10 +4504,10 @@ function soTotpField(plainSecret) {
|
||||
try {
|
||||
const t = await generateTOTP(secret);
|
||||
if (Bridge.copySecure(t.code, 30000)) {
|
||||
toast('Code copied · clears in 30s');
|
||||
toast('Code copied' + clipClearSuffix());
|
||||
} else {
|
||||
navigator.clipboard.writeText(t.code).then(() => {
|
||||
toast('Code copied · clears in 30s');
|
||||
toast('Code copied' + clipClearSuffix());
|
||||
setTimeout(() => navigator.clipboard.writeText('').catch(()=>{}), 30000);
|
||||
});
|
||||
}
|
||||
@@ -5418,9 +5425,9 @@ async function copyPassword(entry) {
|
||||
const p = await decryptPwd(entry.encrypted_password, entry.iv);
|
||||
if (p === '[ERROR]') return toast('Cannot decrypt', 'error');
|
||||
if (Bridge.copySecure(p, 30000)) {
|
||||
toast('Password copied · clears in 30s');
|
||||
toast('Password copied' + clipClearSuffix());
|
||||
} else {
|
||||
navigator.clipboard.writeText(p).then(() => toast('Password copied · clears in 30s'));
|
||||
navigator.clipboard.writeText(p).then(() => toast('Password copied' + clipClearSuffix()));
|
||||
setTimeout(() => navigator.clipboard.writeText('').catch(()=>{}), 30000);
|
||||
}
|
||||
touchEntry(entry.id);
|
||||
@@ -7334,10 +7341,10 @@ async function init() {
|
||||
$('#genCopy').addEventListener('click', () => {
|
||||
if (!genCurrent) return;
|
||||
if (Bridge.copySecure(genCurrent, 30000)) {
|
||||
toast('Copied · clears in 30s');
|
||||
toast('Copied' + clipClearSuffix());
|
||||
} else {
|
||||
navigator.clipboard.writeText(genCurrent).then(() => {
|
||||
toast('Copied · clears in 30s');
|
||||
toast('Copied' + clipClearSuffix());
|
||||
setTimeout(() => navigator.clipboard.writeText('').catch(()=>{}), 30000);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user