Skip to content

Commit

Permalink
Fix resetting markets on browse during back from market
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Feb 7, 2025
1 parent 148bf9b commit e5aead8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions web/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CONTRACTS_PER_SEARCH_PAGE } from 'common/supabase/contracts'
import { buildArray } from 'common/util/array'
import { Button } from 'web/components/buttons/button'
import { usePersistentLocalState } from 'web/hooks/use-persistent-local-state'
import { searchContracts, searchGroups } from 'web/lib/api/api'
import { api, searchGroups } from 'web/lib/api/api'
import { searchUsers } from 'web/lib/supabase/users'
import {
actionColumn,
Expand Down Expand Up @@ -625,7 +625,7 @@ export const useSearchResults = (props: {

try {
const searchPromises: Promise<any>[] = [
searchContracts({
api('search-markets-full', {
term: query,
filter,
sort,
Expand Down Expand Up @@ -694,10 +694,21 @@ export const useSearchResults = (props: {

useDebouncedEffect(
() => {
if (isReady) querySearchResults(true)
if (isReady && !state.contracts?.length) {
querySearchResults(true)
}
},
50,
[isReady]
)
useDebouncedEffect(
() => {
if (isReady) {
querySearchResults(true)
}
},
50,
[isReady, JSON.stringify(searchParams)]
[JSON.stringify(searchParams)]
)

const contracts = state.contracts
Expand Down

0 comments on commit e5aead8

Please sign in to comment.