Skip to content

Commit fe0a705

Browse files
committed
frontend: move routing logic from manage-backups to app.tsx
The main app component already has centralized routing logic in one place that checks for empty device lists and routes accordingly.
1 parent 507db76 commit fe0a705

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

frontends/web/src/app.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ export const App = () => {
8383
return;
8484
}
8585
// if no devices are registered on specified views route to /
86-
if (Object.keys(devices).length === 0 &&
87-
currentURL.startsWith('/settings/device-settings/')) {
86+
if (
87+
Object.keys(devices).length === 0
88+
&& (
89+
currentURL.startsWith('/settings/device-settings/')
90+
|| currentURL.startsWith('/manage-backups/')
91+
)
92+
) {
8893
navigate('/');
8994
return;
9095
}

frontends/web/src/routes/device/manage-backups/manage-backups.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
import { useTranslation } from 'react-i18next';
19-
import { useNavigate } from 'react-router-dom';
2019
import { TDevices } from '@/api/devices';
2120
import { BackButton } from '@/components/backbutton/backbutton';
2221
import { Guide } from '@/components/guide/guide';
@@ -36,10 +35,8 @@ export const ManageBackups = ({
3635
devices,
3736
}: TProps) => {
3837
const { t } = useTranslation();
39-
const navigate = useNavigate();
4038

4139
if (!deviceID || !devices[deviceID]) {
42-
navigate('/');
4340
return null;
4441
}
4542

0 commit comments

Comments
 (0)