Merge pull request #509 from ThibG/glitch-soc/fixes/router-history-navigation

Use history.state to decide whether we should goBack() or go to / (fixes #247)
This commit is contained in:
David Yip
2018-06-06 23:56:48 -05:00
committed by GitHub
5 changed files with 28 additions and 35 deletions

View File

@@ -10,10 +10,10 @@ export default class ColumnBackButton extends React.PureComponent {
handleClick = () => {
// if history is exhausted, or we would leave mastodon, just go to root.
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
this.context.router.history.push('/');
} else {
if (window.history.state) {
this.context.router.history.goBack();
} else {
this.context.router.history.push('/');
}
}

View File

@@ -10,10 +10,10 @@ export default class ColumnBackButtonSlim extends React.PureComponent {
handleClick = () => {
// if history is exhausted, or we would leave mastodon, just go to root.
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
this.context.router.history.push('/');
} else {
if (window.history.state) {
this.context.router.history.goBack();
} else {
this.context.router.history.push('/');
}
}

View File

@@ -66,10 +66,10 @@ export default class ColumnHeader extends React.PureComponent {
handleBackClick = () => {
// if history is exhausted, or we would leave mastodon, just go to root.
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
this.context.router.history.push('/');
} else {
if (window.history.state) {
this.context.router.history.goBack();
} else {
this.context.router.history.push('/');
}
}