Closed ccschmitz closed 1 week ago
To disable polling when sorting by something besides timestamp, modify the useEffect
hook in frontend/src/util/search.ts
. Add a condition to check the sorting criteria and skip polling if it's not by timestamp.
useEffect(() => {
if (skip || sortingCriteria !== 'timestamp') {
return
}
// setup a polling interval for sessions after the current date range
const poll = async () => {
const variables = variableFn()
if (variables === undefined) {
log('search.ts', 'skipping polling for custom time selection')
pollTimeout.current = setTimeout(
poll,
POLL_INTERVAL,
) as unknown as number
return
}
const currentTimeout = pollTimeout.current
const result = await moreDataQuery({ variables })
if (pollTimeout.current === currentTimeout) {
const count = getResultCount(result)
if (count !== undefined) {
setNumMore(count)
}
pollTimeout.current = setTimeout(
poll,
POLL_INTERVAL,
) as unknown as number
}
}
pollTimeout.current = setTimeout(
poll,
POLL_INTERVAL,
) as unknown as number
return () => {
setNumMore(0)
clearTimeout(pollTimeout.current)
pollTimeout.current = undefined
}
}, [getResultCount, moreDataQuery, variableFn, skip, sortingCriteria])
@ccschmitz You mentioned the wrong Zane. I don't contribute to this project.
Talked this over w/ @zane and we agreed it probably wasn't that useful and potentially misleading.