@bobfrankston/rmfmail 1.1.244 → 1.1.245

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,6 +1490,17 @@ 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.)`)) {
1501
+ return;
1502
+ }
1503
+ }
1493
1504
  const statusSync = document.getElementById("status-sync");
1494
1505
  // Optimistic UI: remove from list IMMEDIATELY, then queue the IPC.
1495
1506
  // Old order awaited the daemon round-trip (IPC + DB updates) before
@@ -1499,20 +1510,15 @@ async function deleteSelectedMessages() {
1499
1510
  // re-populates the row and the catch block surfaces the error.
1500
1511
  const snapshot = [...selected];
1501
1512
  removeMessagesAndReconcile(selected);
1502
- // Undo support set immediately too Ctrl+Z works the moment rows
1503
- // disappear from the list, not only after the daemon ACKs. Multi-select
1504
- // deletes only support undo for the first message today (consistent with
1505
- // the previous single-slot semantics); the loop+push pattern can be
1506
- // generalized later if Bob hits it.
1507
- if (snapshot.length === 1) {
1508
- pushUndo({ kind: "delete", at: Date.now(), payload: { ...snapshot[0], subject: "" } });
1509
- if (statusSync)
1510
- statusSync.textContent = `Trashed 1 message (syncing) — Ctrl+Z to undo`;
1511
- }
1512
- else {
1513
- if (statusSync)
1514
- statusSync.textContent = `Trashed ${snapshot.length} messages (syncing)`;
1515
- }
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`;
1516
1522
  // Fire-and-forget per local-first: optimistic remove above already
1517
1523
  // updated the UI; the daemon-side trash is sync DB + queued IMAP.
1518
1524
  // An IPC 120s timeout doesn't mean the trash failed — surfacing it
@@ -1544,10 +1550,17 @@ async function performUndo() {
1544
1550
  const statusSync = document.getElementById("status-sync");
1545
1551
  try {
1546
1552
  if (op.kind === "delete") {
1547
- const { accountId, uid, folderId } = op.payload;
1548
- await undeleteMessage(accountId, uid, folderId);
1553
+ // payload is the full batch (was a single object pre-2026-06-12;
1554
+ // tolerate both shapes so an in-flight undo from an old build
1555
+ // doesn't throw).
1556
+ const msgs = Array.isArray(op.payload) ? op.payload : [op.payload];
1557
+ for (const m of msgs) {
1558
+ await undeleteMessage(m.accountId, m.uid, m.folderId);
1559
+ }
1549
1560
  if (statusSync)
1550
- statusSync.textContent = "Message restored";
1561
+ statusSync.textContent = msgs.length === 1
1562
+ ? "Message restored"
1563
+ : `Restored ${msgs.length} messages`;
1551
1564
  }
1552
1565
  else if (op.kind === "move") {
1553
1566
  const { messages } = op.payload;