@bobfrankston/rmfmail 1.2.206 → 1.2.208

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.
@@ -2668,6 +2668,7 @@ __export(web_settings_exports, {
2668
2668
  loadDeviceState: () => loadDeviceState,
2669
2669
  loadPreferences: () => loadPreferences,
2670
2670
  loadSettings: () => loadSettings,
2671
+ primeSharedConfigs: () => primeSharedConfigs,
2671
2672
  saveAccounts: () => saveAccounts,
2672
2673
  saveAllowlist: () => saveAllowlist,
2673
2674
  saveAutocomplete: () => saveAutocomplete,
@@ -2940,21 +2941,36 @@ async function stashPrevIdb(filename, aboutToBecome) {
2940
2941
  } catch {
2941
2942
  }
2942
2943
  }
2943
- function refreshSharedFile(filename, cached) {
2944
+ async function pullSharedFile(filename, force) {
2944
2945
  const now = Date.now();
2945
- if (now - (__lastSharedRefresh.get(filename) || 0) < SHARED_REFRESH_MS)
2946
- return;
2946
+ if (!force && now - (__lastSharedRefresh.get(filename) || 0) < SHARED_REFRESH_MS)
2947
+ return false;
2947
2948
  __lastSharedRefresh.set(filename, now);
2948
- void (async () => {
2949
+ try {
2950
+ const fresh = await gDriveRead(filename);
2951
+ if (!fresh)
2952
+ return false;
2953
+ const cached = await idbRead(filename);
2954
+ if (fresh === cached)
2955
+ return false;
2956
+ await idbWrite(filename, fresh);
2957
+ console.log(`[settings] ${filename} refreshed from GDrive (shared copy changed)`);
2958
+ return true;
2959
+ } catch {
2960
+ }
2961
+ return false;
2962
+ }
2963
+ function refreshSharedFile(filename, _cached) {
2964
+ void pullSharedFile(filename, false);
2965
+ }
2966
+ async function primeSharedConfigs(force = true) {
2967
+ for (const f of SHARED_FILES) {
2949
2968
  try {
2950
- const fresh = await gDriveRead(filename);
2951
- if (fresh && fresh !== cached) {
2952
- await idbWrite(filename, fresh);
2953
- console.log(`[settings] ${filename} refreshed from GDrive (shared copy changed)`);
2954
- }
2955
- } catch {
2969
+ await pullSharedFile(f, force);
2970
+ } catch (e) {
2971
+ console.warn(`[settings] prime ${f}: ${e?.message || e}`);
2956
2972
  }
2957
- })();
2973
+ }
2958
2974
  }
2959
2975
  async function loadAccounts() {
2960
2976
  const cached = await idbRead("accounts.jsonc");
@@ -3180,7 +3196,7 @@ async function loadDeviceState() {
3180
3196
  }
3181
3197
  return {};
3182
3198
  }
3183
- var IDB_NAME2, IDB_VERSION, STORE_NAME2, gDriveFolderId, gDriveFolderName, gDriveFolderPath, gDriveFolderOwner, tokenProvider, PROVIDERS, DEFAULT_PREFERENCES, DEFAULT_ALLOWLIST, PREV_KEEP, SHARED_REFRESH_MS, __lastSharedRefresh, ALLOWLIST_KEYS, DEVICE_ID_KEY;
3199
+ var IDB_NAME2, IDB_VERSION, STORE_NAME2, gDriveFolderId, gDriveFolderName, gDriveFolderPath, gDriveFolderOwner, tokenProvider, PROVIDERS, DEFAULT_PREFERENCES, DEFAULT_ALLOWLIST, PREV_KEEP, SHARED_REFRESH_MS, SHARED_FILES, __lastSharedRefresh, ALLOWLIST_KEYS, DEVICE_ID_KEY;
3184
3200
  var init_web_settings = __esm({
3185
3201
  "packages/mailx-store-web/web-settings.js"() {
3186
3202
  "use strict";
@@ -3257,6 +3273,7 @@ var init_web_settings = __esm({
3257
3273
  };
3258
3274
  PREV_KEEP = 5;
3259
3275
  SHARED_REFRESH_MS = 5 * 6e4;
3276
+ SHARED_FILES = ["allowlist.jsonc", "preferences.jsonc"];
3260
3277
  __lastSharedRefresh = /* @__PURE__ */ new Map();
3261
3278
  ALLOWLIST_KEYS = ["senders", "domains", "recipients", "flaggedSenders", "flaggedDomains"];
3262
3279
  DEVICE_ID_KEY = "mailx-device-id";
@@ -11401,6 +11418,7 @@ async function initAndroidOnce() {
11401
11418
  } catch (e) {
11402
11419
  console.warn(`[android] List debug: ${e.message}`);
11403
11420
  }
11421
+ primeSharedConfigs().catch((e) => console.warn(`[android] prime shared configs: ${e?.message || e}`));
11404
11422
  narrate("Loading accounts from Google Drive\u2026");
11405
11423
  const gdriveAccounts = await loadAccountsFromCloud();
11406
11424
  console.log(`[android] GDrive returned ${gdriveAccounts.length} accounts: ${gdriveAccounts.map((a) => a.id).join(",")}`);
@@ -11475,6 +11493,7 @@ async function initAndroidOnce() {
11475
11493
  }
11476
11494
  syncManager.syncAll().catch((e) => console.error(`[android] Resume sync error: ${e.message}`));
11477
11495
  service.maybeRefreshContactsConfig().catch((e) => console.error(`[android] resume contacts.jsonc check: ${e?.message || e}`));
11496
+ primeSharedConfigs(false).catch((e) => console.error(`[android] resume shared config check: ${e?.message || e}`));
11478
11497
  }
11479
11498
  });
11480
11499
  console.log("[android] Initialization complete");