DUP-TS-3: onRefresh/onLoadingChange useEffect blocks duplicated in 3 sidebar components #49

Closed
opened 2026-05-27 16:57:40 +02:00 by dries · 0 comments
Owner

Summary

Three sidebar components share byte-for-byte identical useEffect blocks for forwarding state to RightPanel:

  • frontend/src/components/SessionChangesSidebar.tsx lines 96–106
  • frontend/src/components/SessionInfoSidebar.tsx lines 145–153
  • frontend/src/components/WorkingTreeChangesSidebar.tsx lines 95–105

Duplicated code

useEffect(() => { if (!onRefresh) return; onRefresh(refresh); }, [refresh, onRefresh]);
useEffect(() => { if (!onLoadingChange) return; onLoadingChange(loading); }, [loading, onLoadingChange]);

Fix

Extract a custom hook useSidebarCallbacks({ onSummaryChange, onRefresh, onLoadingChange, summary, refresh, loading }).

Effort

Trivial.

## Summary Three sidebar components share byte-for-byte identical `useEffect` blocks for forwarding state to `RightPanel`: - `frontend/src/components/SessionChangesSidebar.tsx` lines 96–106 - `frontend/src/components/SessionInfoSidebar.tsx` lines 145–153 - `frontend/src/components/WorkingTreeChangesSidebar.tsx` lines 95–105 ## Duplicated code ```tsx useEffect(() => { if (!onRefresh) return; onRefresh(refresh); }, [refresh, onRefresh]); useEffect(() => { if (!onLoadingChange) return; onLoadingChange(loading); }, [loading, onLoadingChange]); ``` ## Fix Extract a custom hook `useSidebarCallbacks({ onSummaryChange, onRefresh, onLoadingChange, summary, refresh, loading })`. ## Effort Trivial.
dries closed this issue 2026-07-11 11:23:18 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#49
No description provided.