@bobfrankston/mailx-imap 0.1.47 → 0.1.48

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.
Files changed (2) hide show
  1. package/index.js +20 -1
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -2447,10 +2447,29 @@ export class ImapManager extends EventEmitter {
2447
2447
  this.syncFolder(accountId, folder.id).catch(e => console.error(` [notify] sync ${mailboxPath} failed: ${e.message}`));
2448
2448
  }
2449
2449
  : undefined;
2450
+ // Deletion push: when the server expunges a message from
2451
+ // INBOX while we're parked in IDLE (e.g. the user deletes it
2452
+ // in Thunderbird), reconcile it locally right away instead of
2453
+ // waiting for the 5-minute poll. Debounced — a cleanup pass
2454
+ // fires a burst of EXPUNGE notifications; collapse them into
2455
+ // one syncFolder. syncFolder's set-diff drops the gone rows.
2456
+ let expungeTimer = null;
2457
+ const onExpunge = () => {
2458
+ if (expungeTimer)
2459
+ clearTimeout(expungeTimer);
2460
+ expungeTimer = setTimeout(() => {
2461
+ expungeTimer = null;
2462
+ const inbox = this.db.getFolders(accountId).find(f => f.specialUse === "inbox");
2463
+ if (!inbox)
2464
+ return;
2465
+ console.log(` [idle] ${accountId}: INBOX expunge pushed → reconcile`);
2466
+ this.syncFolder(accountId, inbox.id).catch(e => console.error(` [idle] expunge reconcile failed: ${e.message}`));
2467
+ }, 2000);
2468
+ };
2450
2469
  const stop = await watchClient.watchMailbox("INBOX", (newCount) => {
2451
2470
  console.log(` [idle] ${accountId}: ${newCount} new message(s)`);
2452
2471
  this.syncInboxNewOnly(accountId).catch(e => console.error(` [idle] sync error: ${e.message}`));
2453
- }, { notifySpec, onMailboxStatus });
2472
+ }, { notifySpec, onMailboxStatus, onExpunge });
2454
2473
  this.watchers.set(accountId, async () => {
2455
2474
  await stop();
2456
2475
  await watchClient.logout();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.47",
3
+ "version": "0.1.48",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@bobfrankston/mailx-types": "^0.1.14",
13
13
  "@bobfrankston/mailx-settings": "^0.1.17",
14
- "@bobfrankston/mailx-store": "^0.1.26",
15
- "@bobfrankston/iflow-direct": "^0.1.46",
14
+ "@bobfrankston/mailx-store": "^0.1.27",
15
+ "@bobfrankston/iflow-direct": "^0.1.50",
16
16
  "@bobfrankston/tcp-transport": "^0.1.6",
17
17
  "@bobfrankston/smtp-direct": "^0.1.8",
18
18
  "@bobfrankston/mailx-sync": "^0.1.17",
@@ -39,8 +39,8 @@
39
39
  "dependencies": {
40
40
  "@bobfrankston/mailx-types": "^0.1.14",
41
41
  "@bobfrankston/mailx-settings": "^0.1.17",
42
- "@bobfrankston/mailx-store": "^0.1.26",
43
- "@bobfrankston/iflow-direct": "^0.1.46",
42
+ "@bobfrankston/mailx-store": "^0.1.27",
43
+ "@bobfrankston/iflow-direct": "^0.1.50",
44
44
  "@bobfrankston/tcp-transport": "^0.1.6",
45
45
  "@bobfrankston/smtp-direct": "^0.1.8",
46
46
  "@bobfrankston/mailx-sync": "^0.1.17",