diff --git a/packages/desktop-client/src/components/LoggedInUser.tsx b/packages/desktop-client/src/components/LoggedInUser.tsx
index ec7df311bbf..8ad160f2294 100644
--- a/packages/desktop-client/src/components/LoggedInUser.tsx
+++ b/packages/desktop-client/src/components/LoggedInUser.tsx
@@ -6,6 +6,7 @@ import { useSelector } from 'react-redux';
import { type State } from 'loot-core/src/client/state-types';
import { useActions } from '../hooks/useActions';
+import { useNavigate } from '../hooks/useNavigate';
import { theme, styles } from '../style';
import { Button } from './common/Button2';
@@ -38,9 +39,11 @@ export function LoggedInUser({
getUserData().then(() => setLoading(false));
}, []);
+ const navigate = useNavigate();
+
async function onChangePassword() {
await closeBudget();
- window.__navigate('/change-password');
+ navigate('/change-password');
}
async function onMenuSelect(type) {
@@ -52,14 +55,14 @@ export function LoggedInUser({
break;
case 'sign-in':
await closeBudget();
- window.__navigate('/login');
+ navigate('/login');
break;
case 'sign-out':
signOut();
break;
case 'config-server':
await closeBudget();
- window.__navigate('/config-server');
+ navigate('/config-server');
break;
default:
}
diff --git a/packages/desktop-client/src/components/manager/ConfigServer.tsx b/packages/desktop-client/src/components/manager/ConfigServer.tsx
index 44b13d2e61a..e69e4e16f2b 100644
--- a/packages/desktop-client/src/components/manager/ConfigServer.tsx
+++ b/packages/desktop-client/src/components/manager/ConfigServer.tsx
@@ -111,7 +111,6 @@ export function ConfigServer() {
async function onCreateTestFile() {
await setServerUrl(null);
await createBudget({ testMode: true });
- window.__navigate('/');
}
return (
@@ -250,7 +249,10 @@ export function ConfigServer() {
diff --git a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
index d1041250caf..ac31b5757b2 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
@@ -5,6 +5,7 @@ import { useDispatch } from 'react-redux';
import { importBudget } from 'loot-core/src/client/actions/budgets';
+import { useNavigate } from '../../../hooks/useNavigate';
import { styles, theme } from '../../../style';
import { Block } from '../../common/Block';
import { ButtonWithLoading } from '../../common/Button2';
@@ -31,7 +32,7 @@ function getErrorMessage(error: string): string {
export function ImportActualModal() {
const { t } = useTranslation();
-
+ const navigate = useNavigate();
const dispatch = useDispatch();
const [error, setError] = useState(null);
const [importing, setImporting] = useState(false);
@@ -46,6 +47,7 @@ export function ImportActualModal() {
setError(null);
try {
await dispatch(importBudget(res[0], 'actual'));
+ navigate('/budget');
} catch (err) {
setError(err.message);
} finally {
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
index 3d02baa794a..2c0a52b9318 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
@@ -5,6 +5,7 @@ import { useDispatch } from 'react-redux';
import { importBudget } from 'loot-core/src/client/actions/budgets';
+import { useNavigate } from '../../../hooks/useNavigate';
import { styles, theme } from '../../../style';
import { Block } from '../../common/Block';
import { ButtonWithLoading } from '../../common/Button2';
@@ -23,7 +24,7 @@ function getErrorMessage(error: string): string {
export function ImportYNAB4Modal() {
const { t } = useTranslation();
-
+ const navigate = useNavigate();
const dispatch = useDispatch();
const [error, setError] = useState(null);
const [importing, setImporting] = useState(false);
@@ -38,6 +39,7 @@ export function ImportYNAB4Modal() {
setError(null);
try {
await dispatch(importBudget(res[0], 'ynab4'));
+ navigate('/budget');
} catch (err) {
setError(err.message);
} finally {
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
index a17d9ab74b5..98ee2f49fac 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
@@ -5,6 +5,7 @@ import { useDispatch } from 'react-redux';
import { importBudget } from 'loot-core/src/client/actions/budgets';
+import { useNavigate } from '../../../hooks/useNavigate';
import { styles, theme } from '../../../style';
import { Block } from '../../common/Block';
import { ButtonWithLoading } from '../../common/Button2';
@@ -26,7 +27,7 @@ function getErrorMessage(error: string): string {
export function ImportYNAB5Modal() {
const { t } = useTranslation();
-
+ const navigate = useNavigate();
const dispatch = useDispatch();
const [error, setError] = useState(null);
const [importing, setImporting] = useState(false);
@@ -41,6 +42,7 @@ export function ImportYNAB5Modal() {
setError(null);
try {
await dispatch(importBudget(res[0], 'ynab5'));
+ navigate('/budget');
} catch (err) {
setError(err.message);
} finally {
diff --git a/packages/loot-core/src/client/actions/budgets.ts b/packages/loot-core/src/client/actions/budgets.ts
index 96dc92434a2..5ce240a64b8 100644
--- a/packages/loot-core/src/client/actions/budgets.ts
+++ b/packages/loot-core/src/client/actions/budgets.ts
@@ -161,7 +161,6 @@ export function importBudget(
dispatch(closeModal());
await dispatch(loadPrefs());
- window.__navigate('/budget');
};
}
diff --git a/upcoming-release-notes/3904.md b/upcoming-release-notes/3904.md
new file mode 100644
index 00000000000..2dcbcab90c9
--- /dev/null
+++ b/upcoming-release-notes/3904.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Use useNavigate instead of accessing window.__navigate