@bobfrankston/rmfmail 1.1.245 → 1.1.246

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -1490,14 +1490,25 @@ async function deleteSelectedMessages() {
1490
1490
  return;
1491
1491
  selected.push({ accountId: current.accountId, uid: current.message.uid, folderId: current.message.folderId });
1492
1492
  }
1493
- // SAFETY GATE: confirm before a BULK delete. `Ctrl+A` selects every
1494
- // visible row, and in the "All Inboxes" view that's a scattered screenful
1495
- // across accounts so a single Ctrl+A then Delete could silently trash
1496
- // dozens of messages with no prompt. That is exactly what trashed 114 of
1497
- // Bob's messages on 2026-06-12. A single-message delete (the common quick-
1498
- // triage case) stays instant; anything larger must be confirmed.
1499
- if (selected.length > 1) {
1500
- if (!confirm(`Move ${selected.length} messages to Trash?\n\n(Ctrl+Z restores them if this was a mistake.)`)) {
1493
+ // Deleting a message that is ALREADY in Trash is a PERMANENT expunge, not
1494
+ // a move the service's trashMessage returns "expunged" in that case. So
1495
+ // the prompt and the undo promise must change: permanent delete always
1496
+ // confirms (even a single message) and can't be undone (Bob 2026-06-12).
1497
+ const inTrash = currentFolderSpecialUse === "trash";
1498
+ // SAFETY GATE.
1499
+ // - In Trash: any delete is permanent → always confirm, warn it's final.
1500
+ // - Elsewhere: a single delete is instant (quick triage); a BULK delete
1501
+ // confirms, because `Ctrl+A` selects every visible row and in All
1502
+ // Inboxes that's a scattered screenful — exactly what silently trashed
1503
+ // 114 of Bob's messages on 2026-06-12.
1504
+ const n = selected.length;
1505
+ if (inTrash) {
1506
+ if (!confirm(`Permanently delete ${n} message${n === 1 ? "" : "s"} from Trash?\n\nThis cannot be undone.`)) {
1507
+ return;
1508
+ }
1509
+ }
1510
+ else if (n > 1) {
1511
+ if (!confirm(`Move ${n} messages to Trash?\n\n(Ctrl+Z restores them if this was a mistake.)`)) {
1501
1512
  return;
1502
1513
  }
1503
1514
  }
@@ -1510,15 +1521,21 @@ async function deleteSelectedMessages() {
1510
1521
  // re-populates the row and the catch block surfaces the error.
1511
1522
  const snapshot = [...selected];
1512
1523
  removeMessagesAndReconcile(selected);
1513
- // Undo restores the WHOLE batch, not just the first message — a bulk
1514
- // delete must be fully recoverable via Ctrl+Z (the old single-slot undo
1515
- // left the other N-1 unrecoverable, which made an accidental mass-delete
1516
- // unrecoverable; Bob 2026-06-12).
1517
- pushUndo({ kind: "delete", at: Date.now(), payload: snapshot.map(m => ({ ...m, subject: "" })) });
1518
- if (statusSync)
1519
- statusSync.textContent = snapshot.length === 1
1520
- ? `Trashed 1 message (syncing) Ctrl+Z to undo`
1521
- : `Trashed ${snapshot.length} messages (syncing) Ctrl+Z to undo`;
1524
+ if (inTrash) {
1525
+ // Permanent no undo entry (there's nothing to restore to).
1526
+ if (statusSync)
1527
+ statusSync.textContent = `Permanently deleted ${n} message${n === 1 ? "" : "s"}`;
1528
+ }
1529
+ else {
1530
+ // Undo restores the WHOLE batch, not just the first message — a bulk
1531
+ // delete must be fully recoverable via Ctrl+Z (the old single-slot undo
1532
+ // left the other N-1 unrecoverable; Bob 2026-06-12).
1533
+ pushUndo({ kind: "delete", at: Date.now(), payload: snapshot.map(m => ({ ...m, subject: "" })) });
1534
+ if (statusSync)
1535
+ statusSync.textContent = n === 1
1536
+ ? `Trashed 1 message (syncing) — Ctrl+Z to undo`
1537
+ : `Trashed ${n} messages (syncing) — Ctrl+Z to undo`;
1538
+ }
1522
1539
  // Fire-and-forget per local-first: optimistic remove above already
1523
1540
  // updated the UI; the daemon-side trash is sync DB + queued IMAP.
1524
1541
  // An IPC 120s timeout doesn't mean the trash failed — surfacing it