Fix contract search not adjusting to new user

This commit is contained in:
James Grugett 2022-05-09 15:36:49 -04:00
parent 5b381ef376
commit 3806a5d0d4

View File

@ -28,7 +28,6 @@ const searchClient = algoliasearch(
) )
const indexPrefix = ENV === 'DEV' ? 'dev-' : '' const indexPrefix = ENV === 'DEV' ? 'dev-' : ''
console.log('env', ENV, indexPrefix)
const sortIndexes = [ const sortIndexes = [
{ label: 'Newest', value: indexPrefix + 'contracts-newest' }, { label: 'Newest', value: indexPrefix + 'contracts-newest' },
@ -68,6 +67,11 @@ export function ContractSearch(props: {
<InstantSearch <InstantSearch
searchClient={searchClient} searchClient={searchClient}
indexName={`${indexPrefix}contracts-${sort}`} indexName={`${indexPrefix}contracts-${sort}`}
key={`search-${
querySortOptions?.filter?.tag ??
querySortOptions?.filter?.creatorId ??
''
}`}
> >
<Row className="flex-wrap gap-2"> <Row className="flex-wrap gap-2">
<SearchBox <SearchBox
@ -125,7 +129,6 @@ export function ContractSearchInner(props: {
}) })
useEffect(() => { useEffect(() => {
console.log('initial query', initialQuery)
setQuery(initialQuery) setQuery(initialQuery)
}, [initialQuery]) }, [initialQuery])
@ -134,12 +137,10 @@ export function ContractSearchInner(props: {
}) })
useEffect(() => { useEffect(() => {
console.log('setting query', query)
setQuery(query) setQuery(query)
}, [query]) }, [query])
useEffect(() => { useEffect(() => {
console.log('effect sort', 'curr', index)
const sort = index.split('contracts-')[1] as Sort const sort = index.split('contracts-')[1] as Sort
if (sort) { if (sort) {
setSort(sort) setSort(sort)