Daily trending sort option
This commit is contained in:
parent
5a10132e2b
commit
57190e7876
|
@ -48,6 +48,7 @@ import { Title } from './title'
|
||||||
export const SORTS = [
|
export const SORTS = [
|
||||||
{ label: 'Newest', value: 'newest' },
|
{ label: 'Newest', value: 'newest' },
|
||||||
{ label: 'Trending', value: 'score' },
|
{ label: 'Trending', value: 'score' },
|
||||||
|
{ label: 'Daily trending', value: 'daily-score' },
|
||||||
{ label: '24h volume', value: '24-hour-vol' },
|
{ label: '24h volume', value: '24-hour-vol' },
|
||||||
{ label: 'Last updated', value: 'last-updated' },
|
{ label: 'Last updated', value: 'last-updated' },
|
||||||
{ label: 'Closing soon', value: 'close-date' },
|
{ label: 'Closing soon', value: 'close-date' },
|
||||||
|
@ -88,6 +89,7 @@ export function ContractSearch(props: {
|
||||||
hideGroupLink?: boolean
|
hideGroupLink?: boolean
|
||||||
hideQuickBet?: boolean
|
hideQuickBet?: boolean
|
||||||
noLinkAvatar?: boolean
|
noLinkAvatar?: boolean
|
||||||
|
showProbChange?: boolean
|
||||||
}
|
}
|
||||||
headerClassName?: string
|
headerClassName?: string
|
||||||
persistPrefix?: string
|
persistPrefix?: string
|
||||||
|
@ -128,6 +130,7 @@ export function ContractSearch(props: {
|
||||||
numPages: 1,
|
numPages: 1,
|
||||||
pages: [] as Contract[][],
|
pages: [] as Contract[][],
|
||||||
showTime: null as ShowTime | null,
|
showTime: null as ShowTime | null,
|
||||||
|
showProbChange: false,
|
||||||
},
|
},
|
||||||
!persistPrefix
|
!persistPrefix
|
||||||
? undefined
|
? undefined
|
||||||
|
@ -181,8 +184,9 @@ export function ContractSearch(props: {
|
||||||
const newPage = results.hits as any as Contract[]
|
const newPage = results.hits as any as Contract[]
|
||||||
const showTime =
|
const showTime =
|
||||||
sort === 'close-date' || sort === 'resolve-date' ? sort : null
|
sort === 'close-date' || sort === 'resolve-date' ? sort : null
|
||||||
|
const showProbChange = sort === 'daily-score'
|
||||||
const pages = freshQuery ? [newPage] : [...state.pages, newPage]
|
const pages = freshQuery ? [newPage] : [...state.pages, newPage]
|
||||||
setState({ numPages: results.nbPages, pages, showTime })
|
setState({ numPages: results.nbPages, pages, showTime, showProbChange })
|
||||||
if (freshQuery && isWholePage) window.scrollTo(0, 0)
|
if (freshQuery && isWholePage) window.scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,6 +204,12 @@ export function ContractSearch(props: {
|
||||||
}, 100)
|
}, 100)
|
||||||
).current
|
).current
|
||||||
|
|
||||||
|
const updatedCardUIOptions = useMemo(() => {
|
||||||
|
if (cardUIOptions?.showProbChange === undefined && state.showProbChange)
|
||||||
|
return { ...cardUIOptions, showProbChange: true }
|
||||||
|
return cardUIOptions
|
||||||
|
}, [cardUIOptions, state.showProbChange])
|
||||||
|
|
||||||
const contracts = state.pages
|
const contracts = state.pages
|
||||||
.flat()
|
.flat()
|
||||||
.filter((c) => !additionalFilter?.excludeContractIds?.includes(c.id))
|
.filter((c) => !additionalFilter?.excludeContractIds?.includes(c.id))
|
||||||
|
@ -236,7 +246,7 @@ export function ContractSearch(props: {
|
||||||
showTime={state.showTime ?? undefined}
|
showTime={state.showTime ?? undefined}
|
||||||
onContractClick={onContractClick}
|
onContractClick={onContractClick}
|
||||||
highlightOptions={highlightOptions}
|
highlightOptions={highlightOptions}
|
||||||
cardUIOptions={cardUIOptions}
|
cardUIOptions={updatedCardUIOptions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user