@bobfrankston/rmfmail 1.2.215 → 1.2.216

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.
@@ -9280,17 +9280,23 @@ This cannot be undone.`)) {
9280
9280
  });
9281
9281
  }
9282
9282
  }
9283
+ var undoChain = Promise.resolve();
9284
+ function queueUndo() {
9285
+ undoChain = undoChain.then(() => performUndo()).catch(() => {
9286
+ });
9287
+ }
9283
9288
  async function performUndo() {
9284
9289
  const op = popUndo();
9285
9290
  if (!op) return;
9286
9291
  const statusSync = document.getElementById("status-sync");
9292
+ const remaining = undoStack.length ? ` \u2014 ${undoStack.length} more to undo` : "";
9287
9293
  try {
9288
9294
  if (op.kind === "delete") {
9289
9295
  const msgs = Array.isArray(op.payload) ? op.payload : [op.payload];
9290
9296
  for (const m of msgs) {
9291
9297
  await undeleteMessage(m.accountId, m.uid, m.folderId);
9292
9298
  }
9293
- if (statusSync) statusSync.textContent = msgs.length === 1 ? "Message restored" : `Restored ${msgs.length} messages`;
9299
+ if (statusSync) statusSync.textContent = (msgs.length === 1 ? "Message restored" : `Restored ${msgs.length} messages`) + remaining;
9294
9300
  const first = msgs[0];
9295
9301
  if (first?.folderId) {
9296
9302
  await revealMessage(first.accountId, first.folderId, first.uid);
@@ -9310,7 +9316,7 @@ async function performUndo() {
9310
9316
  if (group.uids.length === 1) await moveMessage2(group.accountId, group.uids[0], group.folderId);
9311
9317
  else await moveMessages2(group.accountId, group.uids, group.folderId);
9312
9318
  }
9313
- if (statusSync) statusSync.textContent = `Undid move of ${messages2.length} message${messages2.length !== 1 ? "s" : ""}`;
9319
+ if (statusSync) statusSync.textContent = `Undid move of ${messages2.length} message${messages2.length !== 1 ? "s" : ""}${remaining}`;
9314
9320
  const firstMoved = messages2[0];
9315
9321
  if (firstMoved?.sourceFolderId) {
9316
9322
  await revealMessage(firstMoved.accountId, firstMoved.sourceFolderId, firstMoved.uid);
@@ -9326,7 +9332,7 @@ async function performUndo() {
9326
9332
  setRowFlagged(entry.accountId, entry.uid, entry.prevFlagged);
9327
9333
  updateMessageFlags(entry.accountId, entry.uid, flagsAfter);
9328
9334
  }
9329
- if (statusSync) statusSync.textContent = `Undid flag change on ${op.payload.length} message${op.payload.length !== 1 ? "s" : ""}`;
9335
+ if (statusSync) statusSync.textContent = `Undid flag change on ${op.payload.length} message${op.payload.length !== 1 ? "s" : ""}${remaining}`;
9330
9336
  }
9331
9337
  reloadCurrentFolder();
9332
9338
  } catch (e) {
@@ -9557,7 +9563,16 @@ async function spamSelectedMessages() {
9557
9563
  g.folderIds.push(msg.folderId);
9558
9564
  byAccount.set(msg.accountId, g);
9559
9565
  }
9560
- if (statusSync) statusSync.textContent = `Spam: ${snapshot.length} queued \u2014 pending server sync`;
9566
+ pushUndo({
9567
+ kind: "move",
9568
+ at: Date.now(),
9569
+ payload: {
9570
+ messages: snapshot.map((m) => ({ accountId: m.accountId, uid: m.uid, sourceFolderId: m.folderId })),
9571
+ targetAccountId: snapshot[0].accountId,
9572
+ targetFolderId: 0
9573
+ }
9574
+ });
9575
+ if (statusSync) statusSync.textContent = `Spam: ${snapshot.length} queued \u2014 Ctrl+Z to undo`;
9561
9576
  for (const [accountId, { uids, folderIds }] of byAccount) {
9562
9577
  markAsSpamMessages(accountId, uids, folderIds).then((result) => {
9563
9578
  console.log(`[spam] ${accountId}: moved ${result?.moved ?? uids.length} to folderId=${result?.targetFolderId}`);
@@ -10903,7 +10918,7 @@ document.addEventListener("keydown", (e) => {
10903
10918
  const composeOpen = !!document.querySelector(".compose-overlay");
10904
10919
  if (!inEditable && !composeOpen && undoStack.length > 0) {
10905
10920
  e.preventDefault();
10906
- performUndo();
10921
+ queueUndo();
10907
10922
  }
10908
10923
  }
10909
10924
  if (e.key === "F5") {
@@ -11060,7 +11075,7 @@ function openShortcutsDialog() {
11060
11075
  ["Forward", "Ctrl+F"],
11061
11076
  ["Sync", "F5"],
11062
11077
  ["Delete selected", "Del or Ctrl+D"],
11063
- ["Undo last delete/move", "Ctrl+Z"],
11078
+ ["Undo delete / move / spam / flag (repeat to go back further)", "Ctrl+Z"],
11064
11079
  ["Toggle read/unread", "R"],
11065
11080
  ["Toggle flag (\u2605)", "(\u2691 button in viewer)"],
11066
11081
  ["Select all visible", "Ctrl+A"],