@bobfrankston/rmfmail 1.2.169 → 1.2.170

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.
@@ -2816,6 +2816,22 @@ function parseJsonc(text) {
2816
2816
  stripped = stripped.replace(/,(\s*[}\]])/g, "$1");
2817
2817
  return JSON.parse(stripped);
2818
2818
  }
2819
+ function refreshSharedFile(filename, cached) {
2820
+ const now = Date.now();
2821
+ if (now - (__lastSharedRefresh.get(filename) || 0) < SHARED_REFRESH_MS)
2822
+ return;
2823
+ __lastSharedRefresh.set(filename, now);
2824
+ void (async () => {
2825
+ try {
2826
+ const fresh = await gDriveRead(filename);
2827
+ if (fresh && fresh !== cached) {
2828
+ await idbWrite(filename, fresh);
2829
+ console.log(`[settings] ${filename} refreshed from GDrive (shared copy changed)`);
2830
+ }
2831
+ } catch {
2832
+ }
2833
+ })();
2834
+ }
2819
2835
  async function loadAccounts() {
2820
2836
  const cached = await idbRead("accounts.jsonc");
2821
2837
  if (cached) {
@@ -2864,6 +2880,7 @@ async function saveAccounts(accounts) {
2864
2880
  async function loadPreferences() {
2865
2881
  const cached = await idbRead("preferences.jsonc");
2866
2882
  if (cached) {
2883
+ refreshSharedFile("preferences.jsonc", cached);
2867
2884
  try {
2868
2885
  const data = parseJsonc(cached);
2869
2886
  return {
@@ -2915,6 +2932,7 @@ async function saveSettings(settings) {
2915
2932
  async function loadAllowlist() {
2916
2933
  const cached = await idbRead("allowlist.jsonc");
2917
2934
  if (cached) {
2935
+ refreshSharedFile("allowlist.jsonc", cached);
2918
2936
  try {
2919
2937
  return parseJsonc(cached);
2920
2938
  } catch {
@@ -3002,7 +3020,7 @@ async function loadDeviceState() {
3002
3020
  }
3003
3021
  return {};
3004
3022
  }
3005
- var IDB_NAME2, IDB_VERSION, STORE_NAME2, gDriveFolderId, gDriveFolderName, gDriveFolderPath, gDriveFolderOwner, tokenProvider, PROVIDERS, DEFAULT_PREFERENCES, DEFAULT_ALLOWLIST, DEVICE_ID_KEY;
3023
+ var IDB_NAME2, IDB_VERSION, STORE_NAME2, gDriveFolderId, gDriveFolderName, gDriveFolderPath, gDriveFolderOwner, tokenProvider, PROVIDERS, DEFAULT_PREFERENCES, DEFAULT_ALLOWLIST, SHARED_REFRESH_MS, __lastSharedRefresh, DEVICE_ID_KEY;
3006
3024
  var init_web_settings = __esm({
3007
3025
  "packages/mailx-store-web/web-settings.js"() {
3008
3026
  "use strict";
@@ -3077,6 +3095,8 @@ var init_web_settings = __esm({
3077
3095
  flaggedSenders: [],
3078
3096
  flaggedDomains: []
3079
3097
  };
3098
+ SHARED_REFRESH_MS = 5 * 6e4;
3099
+ __lastSharedRefresh = /* @__PURE__ */ new Map();
3080
3100
  DEVICE_ID_KEY = "mailx-device-id";
3081
3101
  }
3082
3102
  });