Fix explore page reloading when you navigate back to it in web UI (#27489)

This commit is contained in:
Eugen Rochko 2023-10-23 17:07:13 +02:00 committed by GitHub
commit d9503a1965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 8 deletions

View file

@ -3,12 +3,15 @@ import { PureComponent } from 'react';
import { FormattedMessage } from 'react-intl';
import { withRouter } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import { fetchTrendingLinks } from 'mastodon/actions/trends';
import { DismissableBanner } from 'mastodon/components/dismissable_banner';
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';
import Story from './components/story';
@ -23,10 +26,17 @@ class Links extends PureComponent {
links: ImmutablePropTypes.list,
isLoading: PropTypes.bool,
dispatch: PropTypes.func.isRequired,
...WithRouterPropTypes,
};
componentDidMount () {
const { dispatch } = this.props;
const { dispatch, links, history } = this.props;
// If we're navigating back to the screen, do not trigger a reload
if (history.action === 'POP' && links.size > 0) {
return;
}
dispatch(fetchTrendingLinks());
}
@ -77,4 +87,4 @@ class Links extends PureComponent {
}
export default connect(mapStateToProps)(Links);
export default connect(mapStateToProps)(withRouter(Links));