[Glitch] Fix “Back” button sometimes redirecting out of Mastodon

Port a442a1d1c6 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire
2023-07-17 17:32:46 +02:00
parent c04f2d0cf7
commit 0c45bed333
4 changed files with 36 additions and 15 deletions

View File

@@ -20,9 +20,7 @@ export default class ColumnBackButton extends PureComponent {
handleClick = () => {
const { router } = this.context;
// Check if there is a previous page in the app to go back to per https://stackoverflow.com/a/70532858/9703201
// When upgrading to V6, check `location.key !== 'default'` instead per https://github.com/remix-run/history/blob/main/docs/api-reference.md#location
if (router.route.location.key) {
if (router.history.location?.state?.fromMastodon) {
router.history.goBack();
} else {
router.history.push('/');