From 2c12b621337bd0ad680c9951f1b14773c070bc32 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 22 Jan 2020 09:48:00 -0500 Subject: [PATCH] make sure claim_search is called every time the homepage is navigated to --- ui/component/claimTilesDiscover/view.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/component/claimTilesDiscover/view.jsx b/ui/component/claimTilesDiscover/view.jsx index 2550125d5..b74e7a657 100644 --- a/ui/component/claimTilesDiscover/view.jsx +++ b/ui/component/claimTilesDiscover/view.jsx @@ -39,6 +39,7 @@ function ClaimTilesDiscover(props: Props) { claimType, timestamp, } = props; + const [hasSearched, setHasSearched] = React.useState(false); const options: { page_size: number, @@ -77,7 +78,7 @@ function ClaimTilesDiscover(props: Props) { const claimSearchCacheQuery = createNormalizedClaimSearchKey(options); const uris = claimSearchByQuery[claimSearchCacheQuery] || []; - const shouldPerformSearch = uris.length === 0 || (!loading && uris.length < pageSize); + const shouldPerformSearch = (!hasSearched && uris.length === 0) || (!loading && uris.length < pageSize); // Don't use the query from createNormalizedClaimSearchKey for the effect since that doesn't include page & release_time const optionsStringForEffect = JSON.stringify(options); @@ -85,8 +86,13 @@ function ClaimTilesDiscover(props: Props) { if (shouldPerformSearch) { const searchOptions = JSON.parse(optionsStringForEffect); doClaimSearch(searchOptions); + setHasSearched(true); } - }, [doClaimSearch, shouldPerformSearch, optionsStringForEffect]); + + return () => { + setHasSearched(false); + }; + }, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, setHasSearched]); return (