@bobfrankston/rmfmail 1.2.85 → 1.2.87

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
@@ -1847,7 +1847,7 @@ document.addEventListener("mailx-flagged-batch", (e) => {
1847
1847
  }));
1848
1848
  for (const [src, g] of byAccount) {
1849
1849
  const targetAcct = src === targetAccount ? undefined : targetAccount;
1850
- api.moveMessages(src, g.uids, targetFolderId, targetAcct)?.catch?.((err) => {
1850
+ api.moveMessages(src, g.uids, targetFolderId, g.folderIds, targetAcct)?.catch?.((err) => {
1851
1851
  if (status)
1852
1852
  status.textContent = `Move failed: ${err?.message || err}`;
1853
1853
  });
@@ -1993,16 +1993,22 @@ async function spamSelectedMessages() {
1993
1993
  // simpleParser blocking the event loop). The local commit and server
1994
1994
  // sync still happen. Surfacing it as a failure with an alert lies to
1995
1995
  // the user; the next folder reload reconciles either way.
1996
+ // Collect per-message source folderId alongside the uid. IMAP UIDs are
1997
+ // per-folder, so the service must be told which folder each uid lives in —
1998
+ // a bare (account, uid) lookup can resolve to a same-numbered uid in
1999
+ // another folder, move the wrong message (or no-op), and leave the real
2000
+ // one in INBOX so it reappears on the next list refresh.
1996
2001
  const byAccount = new Map();
1997
2002
  for (const msg of snapshot) {
1998
- const uids = byAccount.get(msg.accountId) || [];
1999
- uids.push(msg.uid);
2000
- byAccount.set(msg.accountId, uids);
2003
+ const g = byAccount.get(msg.accountId) || { uids: [], folderIds: [] };
2004
+ g.uids.push(msg.uid);
2005
+ g.folderIds.push(msg.folderId);
2006
+ byAccount.set(msg.accountId, g);
2001
2007
  }
2002
2008
  if (statusSync)
2003
2009
  statusSync.textContent = `Spam: ${snapshot.length} queued — pending server sync`;
2004
- for (const [accountId, uids] of byAccount) {
2005
- markAsSpamMessages(accountId, uids)
2010
+ for (const [accountId, { uids, folderIds }] of byAccount) {
2011
+ markAsSpamMessages(accountId, uids, folderIds)
2006
2012
  .then(result => {
2007
2013
  console.log(`[spam] ${accountId}: moved ${result?.moved ?? uids.length} to folderId=${result?.targetFolderId}`);
2008
2014
  })