diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx index 73b8948ad500e6b4b28aea607b0d0ac25b35c82c..c6d71930ef8a8be6bf936c1a8ba92e41fc47538a 100644 --- a/packages/desktop-client/src/components/FinancesApp.tsx +++ b/packages/desktop-client/src/components/FinancesApp.tsx @@ -31,6 +31,7 @@ import { TransactionEdit } from './mobile/transactions/TransactionEdit'; import { Notifications } from './Notifications'; import { ManagePayeesPage } from './payees/ManagePayeesPage'; import { Reports } from './reports'; +import { LoadingIndicator } from './reports/LoadingIndicator'; import { NarrowAlternate, WideComponent } from './responsive'; import { Settings } from './settings'; import { FloatableSidebar } from './sidebar'; @@ -65,19 +66,6 @@ function WideNotSupported({ children, redirectTo = '/budget' }) { } function RouterBehaviors() { - const navigate = useNavigate(); - const accounts = useAccounts(); - const accountsLoaded = useSelector( - (state: State) => state.queries.accountsLoaded, - ); - useEffect(() => { - // If there are no accounts, we want to redirect the user to - // the All Accounts screen which will prompt them to add an account - if (accountsLoaded && accounts.length === 0) { - navigate('/accounts'); - } - }, [accountsLoaded, accounts]); - const location = useLocation(); const href = useHref(location); useEffect(() => { @@ -91,6 +79,11 @@ export function FinancesApp() { const dispatch = useDispatch(); const { t } = useTranslation(); + const accounts = useAccounts(); + const accountsLoaded = useSelector( + (state: State) => state.queries.accountsLoaded, + ); + const [lastUsedVersion, setLastUsedVersion] = useLocalPref( 'flags.updateNotificationShownForVersion', ); @@ -180,7 +173,22 @@ export function FinancesApp() { <BankSyncStatus /> <Routes> - <Route path="/" element={<Navigate to="/budget" replace />} /> + <Route + path="/" + element={ + accountsLoaded ? ( + accounts.length > 0 ? ( + <Navigate to="/budget" replace /> + ) : ( + // If there are no accounts, we want to redirect the user to + // the All Accounts screen which will prompt them to add an account + <Navigate to="/accounts" replace /> + ) + ) : ( + <LoadingIndicator /> + ) + } + /> <Route path="/reports/*" element={<Reports />} /> diff --git a/upcoming-release-notes/3503.md b/upcoming-release-notes/3503.md new file mode 100644 index 0000000000000000000000000000000000000000..4ae2f6204acbafc673b9b81c9d2cfc137b5540e2 --- /dev/null +++ b/upcoming-release-notes/3503.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +e2e: improve onboarding test stability.