removeSideBarClass();
}
- fetchProjects = (query: Query) => {
- const { isFavorite } = this.props;
-
- this.setState({ loading: true, query });
-
- fetchProjects({ isFavorite, query }).then((response) => {
- if (this.mounted) {
- this.setState({
- facets: response.facets,
- loading: false,
- pageIndex: 1,
- projects: response.projects,
- total: response.total,
- });
- }
- }, this.stopLoading);
- };
-
fetchMoreProjects = () => {
const { isFavorite } = this.props;
const { pageIndex, projects, query } = this.state;
};
handleQueryChange() {
- const query = parseUrlQuery(this.props.location.query);
+ const { isFavorite } = this.props;
+
+ const queryRaw = this.props.location.query;
+ const query = parseUrlQuery(queryRaw);
+
+ this.setState({ loading: true, query });
- this.fetchProjects(query);
+ fetchProjects({ isFavorite, query }).then((response) => {
+ // We ignore the request if the query changed since the time it was initiated
+ // If that happened, another query will be initiated anyway
+ if (this.mounted && queryRaw === this.props.location.query) {
+ this.setState({
+ facets: response.facets,
+ loading: false,
+ pageIndex: 1,
+ projects: response.projects,
+ total: response.total,
+ });
+ }
+ }, this.stopLoading);
}
handleSortChange = (sort: string, desc: boolean) => {