()
| 234 | * so the collapse effect runs once instead of N× per consumer. |
| 235 | */ |
| 236 | export function useTasksV2WithCollapseEffect(): Task[] | undefined { |
| 237 | const tasks = useTasksV2() |
| 238 | const setAppState = useSetAppState() |
| 239 | |
| 240 | const hidden = tasks === undefined |
| 241 | useEffect(() => { |
| 242 | if (!hidden) return |
| 243 | setAppState(prev => { |
| 244 | if (prev.expandedView !== 'tasks') return prev |
| 245 | return { ...prev, expandedView: 'none' as const } |
| 246 | }) |
| 247 | }, [hidden, setAppState]) |
| 248 | |
| 249 | return tasks |
| 250 | } |
| 251 |
no test coverage detected