@bobfrankston/mailx-sync 0.1.6 → 0.1.7

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 (3) hide show
  1. package/gmail.js +13 -6
  2. package/package.json +3 -3
  3. package/types.d.ts +1 -0
package/gmail.js CHANGED
@@ -377,12 +377,19 @@ export class GmailApiProvider {
377
377
  await Promise.all(Array.from({ length: Math.min(CONCURRENCY, wanted.length) }, () => worker()));
378
378
  }
379
379
  async fetchOne(folder, uid, options = {}) {
380
- // Need to find the Gmail ID from the UID search all messages in folder
381
- const query = `in:${this.folderToLabel(folder)}`;
382
- const ids = await this.listMessageIds(query, 1000);
383
- const id = ids.find(id => idToUid(id) === uid);
384
- if (!id)
385
- return null;
380
+ // Caller (mailx-imap) passes providerId straight from the DB row when
381
+ // available saves the listMessageIds round trip (up to 2 paged calls
382
+ // of 500 IDs each) plus the UID→ID hash search per body fetch. That's
383
+ // the dominant cost for a stuck "Fetching message body..." spinner
384
+ // when Gmail rate-limits.
385
+ let id = options.providerId;
386
+ if (!id) {
387
+ const query = `in:${this.folderToLabel(folder)}`;
388
+ const ids = await this.listMessageIds(query, 1000);
389
+ id = ids.find(id => idToUid(id) === uid);
390
+ if (!id)
391
+ return null;
392
+ }
386
393
  const format = options.source ? "raw" : "metadata";
387
394
  const params = new URLSearchParams({ format });
388
395
  if (format === "metadata") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-sync",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Platform-agnostic mail provider implementations + sync orchestration. Single source of truth for Gmail/IMAP/Outlook protocol code, consumed by both desktop (Node) and Android (WebView) — eliminates the parallel mailx-imap/mailx-store-web Gmail providers that drifted in practice.",
5
5
  "main": "index.js",
6
6
  "types": "index.ts",
@@ -19,7 +19,7 @@
19
19
  "author": "Bob Frankston",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@bobfrankston/iflow-direct": "^0.1.22",
22
+ "@bobfrankston/iflow-direct": "^0.1.23",
23
23
  "@bobfrankston/tcp-transport": "^0.1.4"
24
24
  },
25
25
  "exports": {
@@ -44,7 +44,7 @@
44
44
  },
45
45
  ".transformedSnapshot": {
46
46
  "dependencies": {
47
- "@bobfrankston/iflow-direct": "^0.1.22",
47
+ "@bobfrankston/iflow-direct": "^0.1.23",
48
48
  "@bobfrankston/tcp-transport": "^0.1.4"
49
49
  }
50
50
  }
package/types.d.ts CHANGED
@@ -42,6 +42,7 @@ export interface ProviderMessage {
42
42
  }
43
43
  export interface FetchOptions {
44
44
  source?: boolean;
45
+ providerId?: string;
45
46
  }
46
47
  /**
47
48
  * A mail provider that can list folders, fetch messages, and perform actions.