mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
fix(web): new-session should load a new page rather than fix state
This commit is contained in:
parent
42323a46f6
commit
fa85b30cf0
1 changed files with 9 additions and 2 deletions
|
@ -1,4 +1,3 @@
|
||||||
import { Redirect } from '@reach/router';
|
|
||||||
import { Link } from '@roleypoly/design-system/atoms/typography';
|
import { Link } from '@roleypoly/design-system/atoms/typography';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useSessionContext } from '../../contexts/session/SessionContext';
|
import { useSessionContext } from '../../contexts/session/SessionContext';
|
||||||
|
@ -16,6 +15,15 @@ const NewSession = (props: { sessionID: string }) => {
|
||||||
}
|
}
|
||||||
}, [setPostauthUrl]);
|
}, [setPostauthUrl]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (isAuthenticated) {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.history.replaceState(null, '', '/');
|
||||||
|
window.location.href = postauthUrl;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}, [postauthUrl, isAuthenticated]);
|
||||||
|
|
||||||
React.useCallback(
|
React.useCallback(
|
||||||
(sessionID) => {
|
(sessionID) => {
|
||||||
setupSession(sessionID);
|
setupSession(sessionID);
|
||||||
|
@ -30,7 +38,6 @@ const NewSession = (props: { sessionID: string }) => {
|
||||||
<div>
|
<div>
|
||||||
<Link href={postauthUrl}>If you aren't redirected soon, click here.</Link>
|
<Link href={postauthUrl}>If you aren't redirected soon, click here.</Link>
|
||||||
</div>
|
</div>
|
||||||
{isAuthenticated && <Redirect to={postauthUrl} noThrow replace />}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue