Skip to content

refactor: replace manual fetch effects in PushList with React Query #251

@coopernetes

Description

@coopernetes

Background

PushList.tsx uses a manual useEffect + fetch pattern for loading push records and status counts. This approach has several drawbacks:

  • Triggers react-hooks/set-state-in-effect lint warnings when async state-setting functions are called directly in effect bodies
  • Requires Promise.resolve().then() workarounds to satisfy the lint rule
  • Does not deduplicate concurrent fetches or handle stale data correctly
  • Background refresh intervals are manually managed with setInterval/clearInterval

The load function currently passes the lint check only because the rule was added after that code was written.

Proposed fix

Replace the manual useEffect + fetchPushes / fetchPushCounts calls with React Query (useQuery). This provides:

  • Automatic background refetch on a configurable interval
  • Deduplication of concurrent requests
  • Proper stale-while-revalidate semantics
  • No lint workarounds needed

Scope

  • PushList.tsx — primary target (load and loadCounts effects)
  • Other pages that use manual useEffect + apiFetch may benefit from the same treatment

Notes

  • This is a refactor, not a bug fix — the current workaround (Promise.resolve().then()) is acceptable and consistent with the existing codebase
  • Tracked here to ensure the lint pattern is addressed properly rather than accumulating more workarounds

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions