Refactor schedule functionality in frontend
- Extract schedule logic into custom useSchedule hook - Update BlocklistScheduleSection to use the new hook - Add tests for useSchedule hook - Update documentation with task progress Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,27 +1,3 @@
|
||||
### TASK-PERF-01 — `ConfigListDetail` Calls `sortItems()` on Every Render
|
||||
|
||||
**Where found**
|
||||
`frontend/src/components/config/ConfigListDetail.tsx`. The `sortItems()` function is called directly in the render path without `useMemo`. For config lists with many items (e.g. all filters in a system with many services) this performs an O(n log n) sort on every render, including renders triggered by unrelated state changes.
|
||||
|
||||
**Goal**
|
||||
Wrap the `sortItems()` call in `useMemo` with the items array as dependency:
|
||||
```ts
|
||||
const sortedItems = useMemo(() => sortItems(items), [items]);
|
||||
```
|
||||
Replace all uses of the raw `items` in the render with `sortedItems`.
|
||||
|
||||
**Possible traps and issues**
|
||||
- Verify that `items` array reference is stable (not recreated on every parent render). If the parent passes a new array each time, the `useMemo` will re-sort every render anyway. Trace `items` back to its source hook to confirm stability.
|
||||
- `sortItems` must be a pure function with no side effects for `useMemo` to be safe. Verify this.
|
||||
|
||||
**Docs changes needed**
|
||||
None required.
|
||||
|
||||
**Why this is needed**
|
||||
The Config page is already re-rendering due to multiple concurrent hooks. Adding an O(n log n) sort to each render cycle adds unnecessary CPU work, visible as jank when navigating long filter or action lists.
|
||||
|
||||
---
|
||||
|
||||
### TASK-PERF-02 — `useSchedule` Exposes No `refresh` Function
|
||||
|
||||
**Where found**
|
||||
|
||||
Reference in New Issue
Block a user