Skip to content

Commit f272dd7

Browse files
committed
frontend: replace history entry when redirecting
When automatic navigation occurs (redirects) the history entry should be replaced so that the user can go back. This fixes issues when the user tries to go back but lands on the same page again due to previous route redirecting.
1 parent fe0a705 commit f272dd7

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

frontends/web/src/app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export const App = () => {
100100
}
101101
// if on index page and have at least 1 account, route to /account-summary
102102
if (isIndex && accounts.length) {
103-
navigate('/account-summary');
103+
// replace current history entry so that the user cannot go back to "index"
104+
navigate('/account-summary', { replace: true });
104105
return;
105106
}
106107
// 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/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)