feat(settings): keep backup pwd on disable, dedicated pwd button, tab icons

Auto-backup no longer wipes the stored password when disabled, so
re-enabling reuses it silently. A dedicated "Set/Change backup password"
button (mirrors sync) owns the password, with a warning status when
unset. Corrected the stale hint that claimed the backup pwd was derived
from the master password. Added icons to each settings tab.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-10 16:53:45 +01:00
parent 064ad14156
commit 45ba47f772
5 changed files with 44 additions and 20 deletions
+29 -12
View File
@@ -59,6 +59,18 @@ function refreshAutoBackupUI(cfg) {
$('#autoBackupLast').textContent = cfg.last
? 'Last run: ' + cfg.last.replace('T', ' ').slice(0, 16)
: 'Never run yet';
$('#autoBackupSetPwdBtn').textContent = cfg.hasPwd
? 'Change backup password' : 'Set backup password';
const pwdStatus = $('#autoBackupPwdStatus');
if (cfg.hasPwd) {
pwdStatus.innerHTML = '';
pwdStatus.style.color = 'var(--text-faint)';
pwdStatus.textContent = 'Set.';
} else {
pwdStatus.style.color = 'var(--warning, #e0a800)';
pwdStatus.innerHTML = '<svg width="13" height="13"><use href="#i-alert"/></svg>' +
'<span>Not set — backups won\'t run</span>';
}
}
async function pickAutoBackupFolder() {
@@ -100,27 +112,32 @@ async function promptAndStoreBackupPwd() {
async function onToggleAutoBackup(ev) {
const enabled = ev.target.checked;
if (enabled) {
const cfg = await loadAutoBackupConfig();
if (!cfg.hasPwd && !(await promptAndStoreBackupPwd())) {
ev.target.checked = false;
return;
}
Bridge.setPref(ABK.enabled, '1');
$('#autoBackupConfig').style.display = '';
toast('Auto-backup enabled');
// Refresh the dir/last display in case we came from cold state.
const fresh = await loadAutoBackupConfig();
refreshAutoBackupUI(fresh);
// No pwd prompt here — the dedicated "Set backup password" button
// owns it (like sync). Backups no-op until it's set.
const cfg = await loadAutoBackupConfig();
refreshAutoBackupUI(cfg);
toast(cfg.hasPwd ? 'Auto-backup enabled'
: 'Auto-backup enabled — set a backup password to start');
} else {
Bridge.setPref(ABK.enabled, '');
// Forget the stored backup pwd so re-enabling prompts fresh —
// gives the user a way to change it without extra UI.
Bridge.setPref(ABK.pwd, '');
// Keep the stored pwd re-enabling reuses it silently. Change it
// anytime via the dedicated "Change backup password" button.
$('#autoBackupConfig').style.display = 'none';
toast('Auto-backup disabled');
}
}
// Dedicated pwd button (mirrors sync's syncSetEncPwdFlow) so the user can
// change the backup password without the disable/re-enable dance.
async function changeBackupPwd() {
if (await promptAndStoreBackupPwd()) {
refreshAutoBackupUI(await loadAutoBackupConfig());
toast('Backup password saved');
}
}
async function runAutoBackupNow(silent) {
const cfg = await loadAutoBackupConfig();
if (!cfg) return silent || toast('Bridge not available', 'error');