From 39745e050a9664d9def278b1a8c88c2c230dadf6 Mon Sep 17 00:00:00 2001 From: abias Date: Fri, 9 Jun 2023 13:23:43 -0400 Subject: [PATCH] Fix search page update url --- src/shared/components/search.tsx | 15 ++++++++------- src/shared/utils.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index d636c34b..642fd3c7 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -285,7 +285,7 @@ export class Search extends Component { }; } - if (q !== "") { + if (q) { this.state = { ...this.state, searchRes, @@ -411,9 +411,10 @@ export class Search extends Component { {this.selects} {this.searchForm} {this.displayResults(type)} - {this.resultsCount === 0 && this.state.searchRes.state == "success" && ( - {i18n.t("no_results")} - )} + {this.resultsCount === 0 && + this.state.searchRes.state === "success" && ( + {i18n.t("no_results")} + )} ); @@ -861,7 +862,7 @@ export class Search extends Component { const { communityId, creatorId, type, sort, listingType, page } = getSearchQueryParams(); - if (q && q !== "") { + if (q) { this.setState({ searchRes: { state: "loading" } }); this.setState({ searchRes: await HttpService.client.search({ @@ -992,7 +993,7 @@ export class Search extends Component { i.setState({ searchText: event.target.value }); } - updateUrl({ + async updateUrl({ q, type, listingType, @@ -1029,6 +1030,6 @@ export class Search extends Component { this.props.history.push(`/search${getQueryString(queryParams)}`); - this.search(); + await this.search(); } } diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 8339a1ad..86c21dcf 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -1176,7 +1176,7 @@ export function setIsoData(context: any): IsoData { * Tells the node server to load the data from the isoData, or the browser to fetch it. */ export function isInitialRoute(isoData: IsoData, context: any): boolean { - return isoData.path == context.router.route.match.url; + return isoData.path === context.router.route.match.url; } moment.updateLocale("en", {