From: SleeplessOne1917 Date: Sun, 25 Jun 2023 17:07:18 +0000 (-0400) Subject: Fix search request being called twice on search page X-Git-Url: http://these/git/%22https:/www.exeterceilidhs.net/%22%7B%7D/%7Bthis.captchaPngSrc%28%29%7D?a=commitdiff_plain;h=25cab15cfa489da4161d098fb491573efd8ffaf6;p=lemmy-ui.git Fix search request being called twice on search page --- diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 473b18c..b58580e 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -332,7 +332,9 @@ export class Search extends Component { } async componentDidMount() { - if (!this.state.isIsomorphic) { + if ( + !(this.state.isIsomorphic || this.props.history.location.state?.searched) + ) { const promises = [this.fetchCommunities()]; if (this.state.searchText) { promises.push(this.search()); @@ -1095,7 +1097,9 @@ export class Search extends Component { sort: sort ?? urlSort, }; - this.props.history.push(`/search${getQueryString(queryParams)}`); + this.props.history.push(`/search${getQueryString(queryParams)}`, { + searched: true, + }); await this.search(); }