fix(practice): show active sessions for teacher's own children

The useUnifiedStudents hook was only subscribing to child session
updates for non-teachers. When a user is both a teacher AND a parent,
their child's active session wouldn't show on /practice unless the
child was also present in the classroom.

Changed from `!isTeacher` to `hasChildren` so the child session socket
is enabled for ALL users who have children.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-12-29 11:36:06 -06:00
parent 91d6d6a1b6
commit ece319738b

View File

@@ -78,10 +78,11 @@ export function useUnifiedStudents(
useActiveSessionsInClassroom(classroom?.id)
// Get active sessions for parent's children (via WebSocket for real-time updates)
// Only active for non-teachers (parents) who have children
// Enabled for ALL users who have children (teachers can also be parents)
const hasChildren = childIds.length > 0
const { sessionMap: childSessionMap, isLoading: isLoadingChildSessions } = useChildSessionsSocket(
!isTeacher ? userId : undefined,
!isTeacher ? childIds : EMPTY_CHILD_IDS
hasChildren ? userId : undefined,
hasChildren ? childIds : EMPTY_CHILD_IDS
)
// Build lookup maps for efficient merging
@@ -232,7 +233,7 @@ export function useUnifiedStudents(
isLoadingClassroom ||
isLoadingChildren ||
(isTeacher && (isLoadingEnrolled || isLoadingPresence || isLoadingActiveSessions)) ||
(!isTeacher && isLoadingChildSessions)
(hasChildren && isLoadingChildSessions)
return {
students,