Skip to content

Commit b866842

Browse files
committed
Merge branch 'frontend-prevent-history'
2 parents 507db76 + f272dd7 commit b866842

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

frontends/web/src/app.tsx

Lines changed: 9 additions & 3 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
}
@@ -95,7 +100,8 @@ export const App = () => {
95100
}
96101
// if on index page and have at least 1 account, route to /account-summary
97102
if (isIndex && accounts.length) {
98-
navigate('/account-summary');
103+
// replace current history entry so that the user cannot go back to "index"
104+
navigate('/account-summary', { replace: true });
99105
return;
100106
}
101107
// if on the /buy/ view and there are no accounts view route to /

frontends/web/src/routes/bitsurance/account.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export const BitsuranceAccount = ({ code, accounts }: TProps) => {
7070
if (!connectResult.success) {
7171
return;
7272
}
73-
navigate(`/bitsurance/widget/${btcAccounts[0].code}`);
73+
// replace current history item when redirecting so that the user can go back
74+
navigate(`/bitsurance/widget/${btcAccounts[0].code}`, { replace: true });
7475
});
7576
}
7677
}, [btcAccounts, navigate]);

frontends/web/src/routes/bitsurance/bitsurance.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export const Bitsurance = ({ accounts }: TProps) => {
4747

4848
useEffect(() => {
4949
if (accounts.some(({ bitsuranceStatus }) => bitsuranceStatus)) {
50-
navigate('/bitsurance/dashboard');
50+
// replace current history item when redirecting so that the user can go back
51+
navigate('/bitsurance/dashboard', { replace: true });
5152
} else {
5253
setRedirecting(false);
5354
}

frontends/web/src/routes/buy/info.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export const BuyInfo = ({ code, accounts }: TProps) => {
5858
const accountCode = supportedAccounts[0].code;
5959
connectKeystore(accountCode).then(connected => {
6060
if (connected) {
61-
navigate(`/buy/exchange/${accountCode}`);
61+
// replace current history item when redirecting so that the user can go back
62+
navigate(`/buy/exchange/${accountCode}`, { replace: true });
6263
}
6364
});
6465
}

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

frontends/web/src/routes/settings/mobile-settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export const MobileSettings = ({ deviceIDs, hasAccounts }: TPagePropsWithSetting
3737
const { t } = useTranslation();
3838
useEffect(() => {
3939
if (!isMobile) {
40-
navigate('/settings/general');
40+
// replace current history item when redirecting so that the user can go back
41+
navigate('/settings/general', { replace: true });
4142
}
4243
}, [isMobile, navigate]);
4344
return (

0 commit comments

Comments
 (0)