@bobfrankston/rmfmail 1.1.33 → 1.1.35

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.
@@ -6090,8 +6090,40 @@ ${bodyEncoded}`;
6090
6090
  hasBccHistoryTo(_email) {
6091
6091
  return false;
6092
6092
  }
6093
+ /** Pull the shared GDrive `contacts.jsonc` and merge its entries into the
6094
+ * local contacts table. Desktop flushes the full union there (everything
6095
+ * it discovered from its mailbox corpus + Google contacts + preferred);
6096
+ * this is how an Android device gets contacts it never saw in its own
6097
+ * (partial) on-device corpus. Called once at startup — re-importing on a
6098
+ * loop would bump `use_count` every pass and distort autocomplete rank. */
6093
6099
  async loadContactsConfig() {
6094
- return null;
6100
+ try {
6101
+ const { cloudRead: cloudRead2 } = await Promise.resolve().then(() => (init_web_settings(), web_settings_exports));
6102
+ const raw = await cloudRead2("contacts.jsonc");
6103
+ if (!raw)
6104
+ return null;
6105
+ const cfg = parseJsoncLoose(raw);
6106
+ if (!cfg)
6107
+ return null;
6108
+ let imported = 0;
6109
+ for (const list of [cfg.preferred, cfg.discovered]) {
6110
+ if (!Array.isArray(list))
6111
+ continue;
6112
+ for (const e of list) {
6113
+ const email = (e?.email || "").trim();
6114
+ if (!email)
6115
+ continue;
6116
+ this.db.recordSentAddress((e?.name || "").trim(), email);
6117
+ imported++;
6118
+ }
6119
+ }
6120
+ if (imported > 0)
6121
+ console.log(`[contacts] loaded ${imported} from contacts.jsonc`);
6122
+ return { imported };
6123
+ } catch (e) {
6124
+ console.error(`[contacts] loadContactsConfig failed: ${e?.message || e}`);
6125
+ return null;
6126
+ }
6095
6127
  }
6096
6128
  // Calendar — Android UI has its own native calendar; no JS-side data.
6097
6129
  async getCalendarEvents(_fromMs, _toMs) {
@@ -10131,6 +10163,9 @@ function setContactsSyncToken(accountId, token) {
10131
10163
  } catch {
10132
10164
  }
10133
10165
  }
10166
+ function isGoogleAccount(account) {
10167
+ return !!(account.imap?.host?.toLowerCase().includes("gmail") || account.email?.toLowerCase().endsWith("@gmail.com"));
10168
+ }
10134
10169
  async function syncGoogleContactsForAccount(db2, accountId, tokenProvider2) {
10135
10170
  const inFlight = contactsSyncing.get(accountId);
10136
10171
  if (inFlight) return inFlight;
@@ -10351,8 +10386,9 @@ async function initAndroid() {
10351
10386
  }
10352
10387
  })();
10353
10388
  }
10389
+ service.loadContactsConfig().catch((e) => console.error(`[android] startup contacts.jsonc load: ${e?.message || e}`));
10354
10390
  for (const account of db.getAccounts()) {
10355
- if (!account.email) continue;
10391
+ if (!account.email || !isGoogleAccount(account)) continue;
10356
10392
  const tp = createNativeTokenProvider(account.email);
10357
10393
  syncGoogleContactsForAccount(db, account.id, tp).catch((e) => console.error(`[android] startup contacts sync ${account.id}: ${e.message}`));
10358
10394
  }
@@ -10368,7 +10404,7 @@ async function initAndroid() {
10368
10404
  syncManager.syncAll().catch((e) => console.error(`[android] Periodic sync error: ${e.message}`));
10369
10405
  if (++contactsSyncTickCounter % 8 === 0) {
10370
10406
  for (const account of db.getAccounts()) {
10371
- if (!account.email) continue;
10407
+ if (!account.email || !isGoogleAccount(account)) continue;
10372
10408
  const tp = createNativeTokenProvider(account.email);
10373
10409
  syncGoogleContactsForAccount(db, account.id, tp).catch((e) => console.error(`[android] periodic contacts sync ${account.id}: ${e.message}`));
10374
10410
  }