A local-first personal finance app
Add force reload button to settings (#6090)
Matiss Janis Aboltinsda3f4c309130
diff --git a/packages/desktop-client/src/components/settings/Experimental.tsx b/packages/desktop-client/src/components/settings/Experimental.tsxindex 01e32f9b14..b11784e5d8 100644--- a/packages/desktop-client/src/components/settings/Experimental.tsx+++ b/packages/desktop-client/src/components/settings/Experimental.tsx@@ -171,6 +171,9 @@ export function ExperimentalFeatures() {><Trans>Crossover Report</Trans></FeatureToggle>+ <FeatureToggle flag="forceReload">+ <Trans>Force reload app button</Trans>+ </FeatureToggle><GlobalFeatureToggleprefName="plugins"disableToggle={true}diff --git a/packages/desktop-client/src/components/settings/Reset.tsx b/packages/desktop-client/src/components/settings/Reset.tsxindex 1dc794c598..0d61e5f823 100644--- a/packages/desktop-client/src/components/settings/Reset.tsx+++ b/packages/desktop-client/src/components/settings/Reset.tsx@@ -5,6 +5,7 @@ import { ButtonWithLoading } from '@actual-app/components/button';import { Text } from '@actual-app/components/text';import { send } from 'loot-core/platform/client/fetch';+import { isElectron } from 'loot-core/shared/environment';import { Setting } from './UI';@@ -88,3 +89,47 @@ export function ResetSync() {</Setting>);}++export function ForceReload() {+ const [reloading, setReloading] = useState(false);++ async function onForceReload() {+ setReloading(true);+ try {+ if (isElectron()) {+ // For Electron, use location.reload()+ window.location.reload();+ } else {+ // For browser, use Actual.reload() which unregisters service worker+ // and forces a fresh load+ if (window.Actual?.reload) {+ await window.Actual.reload();+ } else {+ window.location.reload();+ }+ }+ } catch (error) {+ // If reload fails, fall back to location.reload()+ window.location.reload();+ }+ }++ return (+ <Setting+ primaryAction={+ <ButtonWithLoading isLoading={reloading} onPress={onForceReload}>+ <Trans>Force reload app</Trans>+ </ButtonWithLoading>+ }+ >+ <Text>+ <Trans>+ <strong>Force reload app</strong> will clear the cached version of the+ app and load a fresh one. This is useful if you're experiencing+ issues with the app after an update or if cached files are causing+ problems. The app will reload automatically after clearing the cache.+ </Trans>+ </Text>+ </Setting>+ );+}diff --git a/packages/desktop-client/src/components/settings/index.tsx b/packages/desktop-client/src/components/settings/index.tsxindex 2fa4735c4b..f2465fd3e7 100644--- a/packages/desktop-client/src/components/settings/index.tsx+++ b/packages/desktop-client/src/components/settings/index.tsx@@ -23,7 +23,7 @@ import { ExportBudget } from './Export';import { FormatSettings } from './Format';import { LanguageSettings } from './LanguageSettings';import { RepairTransactions } from './RepairTransactions';-import { ResetCache, ResetSync } from './Reset';+import { ForceReload, ResetCache, ResetSync } from './Reset';import { ThemeSettings } from './Themes';import { AdvancedToggle, Setting } from './UI';@@ -176,6 +176,7 @@ export function Settings() {const [budgetName] = useMetadataPref('budgetName');const dispatch = useDispatch();const isCurrencyExperimentalEnabled = useFeatureFlag('currency');+ const isForceReloadEnabled = useFeatureFlag('forceReload');const [_, setDefaultCurrencyCodePref] = useSyncedPref('defaultCurrencyCode');const onCloseBudget = () => {@@ -246,6 +247,7 @@ export function Settings() {<ExportBudget /><AdvancedToggle><AdvancedAbout />+ {isForceReloadEnabled && <ForceReload />}<ResetCache /><ResetSync /><RepairTransactions />diff --git a/packages/desktop-client/src/hooks/useFeatureFlag.ts b/packages/desktop-client/src/hooks/useFeatureFlag.tsindex 0976854517..14d4f255d0 100644--- a/packages/desktop-client/src/hooks/useFeatureFlag.ts+++ b/packages/desktop-client/src/hooks/useFeatureFlag.ts@@ -10,6 +10,7 @@ const DEFAULT_FEATURE_FLAG_STATE: Record<FeatureFlag, boolean> = {currency: false,crossoverReport: false,plugins: false,+ forceReload: false,};export function useFeatureFlag(name: FeatureFlag): boolean {diff --git a/packages/loot-core/src/types/prefs.ts b/packages/loot-core/src/types/prefs.tsindex 94ab7cd0d7..f00e239bf1 100644--- a/packages/loot-core/src/types/prefs.ts+++ b/packages/loot-core/src/types/prefs.ts@@ -5,7 +5,8 @@ export type FeatureFlag =| 'formulaMode'| 'currency'| 'crossoverReport'- | 'plugins';+ | 'plugins'+ | 'forceReload';/*** Cross-device preferences. These sync across devices when they are changed.diff --git a/upcoming-release-notes/6090.md b/upcoming-release-notes/6090.mdnew file mode 100644index 0000000000..9ed94973d3--- /dev/null+++ b/upcoming-release-notes/6090.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MatissJanis]+---++Add "Force reload app" button to Advanced settings section to clear cached app version and load a fresh one