[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

@@ -528,11 +528,12 @@ class UI extends Component {
};
handleHotkeyBack = () => {
// if history is exhausted, or we would leave mastodon, just go to root.
if (window.history.state) {
this.props.history.goBack();
const { history } = this.props;
if (history.location?.state?.fromMastodon) {
history.goBack();
} else {
this.props.history.push('/');
history.push('/');
}
};