From f51ec5044336d28c0ff01f02e737aa6e4b3d18a8 Mon Sep 17 00:00:00 2001 From: Shuki Vaknin Date: Sat, 27 Jun 2026 00:17:08 +0300 Subject: [PATCH] feat(settings): add "Refresh cached data" recovery action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the mailbox view gets into a stale or wrong state, the only escape was the browser's "clear site data" — which also wipes the saved account list, forcing a re-login of every account. Add a non-destructive "Refresh cached data" button under Settings → Data. It clears the server-derived caches (contacts, calendars, identities, per-account snapshots) and reloads so they re-fetch fresh, while preserving accounts, sessions, settings, themes and user content (templates, S/MIME). Two-click confirm to avoid an accidental reload. English strings added across all locales (translation follow-up); unit tests cover the cache-clear (keeps account-registry/auth/prefs) and the reload. --- components/settings/about-data-settings.tsx | 21 +++++++++ lib/__tests__/clear-cached-data.test.ts | 50 +++++++++++++++++++++ lib/clear-cached-data.ts | 45 +++++++++++++++++++ locales/cs/common.json | 5 +++ locales/da/common.json | 5 +++ locales/de/common.json | 5 +++ locales/en/common.json | 5 +++ locales/es/common.json | 5 +++ locales/fa/common.json | 5 +++ locales/fr/common.json | 5 +++ locales/hu/common.json | 5 +++ locales/it/common.json | 5 +++ locales/ja/common.json | 5 +++ locales/ko/common.json | 5 +++ locales/lv/common.json | 5 +++ locales/nl/common.json | 5 +++ locales/pl/common.json | 5 +++ locales/pt/common.json | 5 +++ locales/ro/common.json | 5 +++ locales/ru/common.json | 5 +++ locales/tr/common.json | 5 +++ locales/uk/common.json | 5 +++ locales/zh/common.json | 5 +++ 23 files changed, 216 insertions(+) create mode 100644 lib/__tests__/clear-cached-data.test.ts create mode 100644 lib/clear-cached-data.ts diff --git a/components/settings/about-data-settings.tsx b/components/settings/about-data-settings.tsx index 7bbde4a7..0c0556b9 100644 --- a/components/settings/about-data-settings.tsx +++ b/components/settings/about-data-settings.tsx @@ -11,6 +11,7 @@ import { useUpdateStore } from '@/stores/update-store'; import { ExternalLink } from 'lucide-react'; import { cn } from '@/lib/utils'; import { getPathPrefix } from '@/lib/browser-navigation'; +import { clearCachedData } from '@/lib/clear-cached-data'; import { SpamSiegeGame } from './spam-siege-game'; const APP_VERSION = process.env.NEXT_PUBLIC_APP_VERSION || "0.0.0"; @@ -54,6 +55,7 @@ export function AboutDataSettings() { useSettingsStore(); const { settingsSyncEnabled } = useConfig(); const [showResetConfirm, setShowResetConfirm] = useState(false); + const [showRefreshConfirm, setShowRefreshConfirm] = useState(false); const fileInputRef = useRef(null); const { isFeatureEnabled } = usePolicyStore(); const [showGame, setShowGame] = useState(false); @@ -105,6 +107,15 @@ export function AboutDataSettings() { reader.readAsText(file); }; + const handleRefreshCache = () => { + if (showRefreshConfirm) { + clearCachedData(); // reloads the page + } else { + setShowRefreshConfirm(true); + setTimeout(() => setShowRefreshConfirm(false), 5000); + } + }; + const handleReset = () => { if (showResetConfirm) { resetToDefaults(); @@ -187,6 +198,16 @@ export function AboutDataSettings() { )} + + + +