@bobfrankston/rmfmail 1.2.216 → 1.2.219

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.
@@ -360,8 +360,9 @@ function deleteMessages(accountId, uids, folderIds) {
360
360
  return ipc().deleteMessages?.(accountId, uids, folderIds);
361
361
  }
362
362
  function moveMessages(accountId, uids, targetFolderId, folderIds, targetAccountId) {
363
- if (uids.length === 1)
363
+ if (uids.length === 1 && (targetAccountId || !folderIds?.length)) {
364
364
  return moveMessage(accountId, uids[0], targetFolderId, targetAccountId);
365
+ }
365
366
  return ipc().moveMessages?.(accountId, uids, targetFolderId, folderIds);
366
367
  }
367
368
  function markAsSpamMessages(accountId, uids, folderIds) {
@@ -9304,17 +9305,17 @@ async function performUndo() {
9304
9305
  return;
9305
9306
  }
9306
9307
  } else if (op.kind === "move") {
9307
- const { messages: messages2 } = op.payload;
9308
+ const { messages: messages2, targetFolderId } = op.payload;
9308
9309
  const byDest = /* @__PURE__ */ new Map();
9309
9310
  for (const m of messages2) {
9310
9311
  const key = `${m.accountId}:${m.sourceFolderId}`;
9311
9312
  if (!byDest.has(key)) byDest.set(key, { accountId: m.accountId, folderId: m.sourceFolderId, uids: [] });
9312
9313
  byDest.get(key).uids.push(m.uid);
9313
9314
  }
9314
- const { moveMessages: moveMessages2, moveMessage: moveMessage2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
9315
+ const { moveMessages: moveMessages2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
9315
9316
  for (const group of byDest.values()) {
9316
- if (group.uids.length === 1) await moveMessage2(group.accountId, group.uids[0], group.folderId);
9317
- else await moveMessages2(group.accountId, group.uids, group.folderId);
9317
+ const currentFolderIds = targetFolderId ? group.uids.map(() => targetFolderId) : void 0;
9318
+ await moveMessages2(group.accountId, group.uids, group.folderId, currentFolderIds);
9318
9319
  }
9319
9320
  if (statusSync) statusSync.textContent = `Undid move of ${messages2.length} message${messages2.length !== 1 ? "s" : ""}${remaining}`;
9320
9321
  const firstMoved = messages2[0];
@@ -9563,19 +9564,18 @@ async function spamSelectedMessages() {
9563
9564
  g.folderIds.push(msg.folderId);
9564
9565
  byAccount.set(msg.accountId, g);
9565
9566
  }
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
- });
9567
+ const spamUndo = {
9568
+ messages: snapshot.map((m) => ({ accountId: m.accountId, uid: m.uid, sourceFolderId: m.folderId })),
9569
+ targetAccountId: snapshot[0].accountId,
9570
+ targetFolderId: 0
9571
+ // filled in below only the service knows which folder is \Junk
9572
+ };
9573
+ pushUndo({ kind: "move", at: Date.now(), payload: spamUndo });
9575
9574
  if (statusSync) statusSync.textContent = `Spam: ${snapshot.length} queued \u2014 Ctrl+Z to undo`;
9576
9575
  for (const [accountId, { uids, folderIds }] of byAccount) {
9577
9576
  markAsSpamMessages(accountId, uids, folderIds).then((result) => {
9578
9577
  console.log(`[spam] ${accountId}: moved ${result?.moved ?? uids.length} to folderId=${result?.targetFolderId}`);
9578
+ if (result?.targetFolderId) spamUndo.targetFolderId = result.targetFolderId;
9579
9579
  }).catch((e) => {
9580
9580
  console.error(`[spam] ${accountId} failed:`, e);
9581
9581
  if (statusSync) statusSync.textContent = `Spam sync issue (${accountId}): ${e?.message || e}`;