Extract generic useListData hook for shared list fetching

This commit is contained in:
2026-04-21 17:53:58 +02:00
parent e683108965
commit e244a85291
9 changed files with 232 additions and 169 deletions

View File

@@ -304,7 +304,9 @@ Issues are grouped by category and ordered roughly by severity. Each entry descr
---
### TASK-016 — Extract generic `useListData` hook to eliminate duplicated fetch-list pattern
### TASK-016 — Extract generic `useListData` hook to eliminate duplicated fetch-list pattern (done)
**Where fixed:** `frontend/src/hooks/useListData.ts`, `frontend/src/hooks/useActionList.ts`, `frontend/src/hooks/useFilterList.ts`, `frontend/src/hooks/useJailConfigs.ts`, `frontend/src/hooks/useBlocklists.ts`, `frontend/src/api/config.ts`, `frontend/src/api/blocklist.ts`, `frontend/src/hooks/__tests__/useListData.test.ts`
**Where found:** `frontend/src/hooks/useActionList.ts`, `useFilterList.ts`, `useJailConfigs.ts`, and `useBlocklists.ts` each contain ~40 lines of nearly identical code: `useState` for data/loading/error, a `useRef<AbortController>`, a `refresh` callback with abort-create-set-loading-fetch-set logic, and a `useEffect` that calls `refresh` on mount.