Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable polling when sorting by something besides timestamp #8594

Closed
ccschmitz opened this issue May 16, 2024 — with Linear · 3 comments
Closed

Disable polling when sorting by something besides timestamp #8594

ccschmitz opened this issue May 16, 2024 — with Linear · 3 comments
Assignees

Comments

Copy link
Contributor

Talked this over w/ @zane and we agreed it probably wasn't that useful and potentially misleading.

@ccschmitz ccschmitz self-assigned this May 16, 2024
Copy link

linear bot commented May 16, 2024

Copy link

greptile-apps bot commented May 16, 2024

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])

References

/frontend/src/util/search.ts

Ask Greptile

@zane
Copy link

zane commented May 16, 2024

@ccschmitz You mentioned the wrong Zane. I don't contribute to this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants