fix: scope instructor chat threads to the selected course

This commit is contained in:
2026-08-11 14:19:52 +09:00
parent 5d2c93dd40
commit 4869dbe4c1
5 changed files with 12 additions and 10 deletions
+5 -4
View File
@@ -15,6 +15,7 @@ import type { AuthSession } from '../types/auth';
type InstructorChatPanelProps = {
session: AuthSession;
courseId: string;
open: boolean;
initialThreadId?: string | null;
initialThreadRequestId?: number;
@@ -30,7 +31,7 @@ type ChatNotificationPayload = {
createdAt: string;
};
export function InstructorChatPanel({ session, open, initialThreadId = null, initialThreadRequestId = 0, onClose }: InstructorChatPanelProps) {
export function InstructorChatPanel({ session, courseId, open, initialThreadId = null, initialThreadRequestId = 0, onClose }: InstructorChatPanelProps) {
const [threads, setThreads] = useState<InstructorChatThread[]>([]);
const [selectedThreadId, setSelectedThreadId] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
@@ -45,7 +46,7 @@ export function InstructorChatPanel({ session, open, initialThreadId = null, ini
if (showLoading) setLoading(true);
setError(null);
const request = listInstructorChatThreads(session.accessToken)
const request = listInstructorChatThreads(session.accessToken, courseId)
.then((items) => {
if (!cancelled) setThreads(items);
})
@@ -91,7 +92,7 @@ export function InstructorChatPanel({ session, open, initialThreadId = null, ini
return () => {
refresh.cancel();
};
}, [open, session.accessToken]);
}, [courseId, open, session.accessToken]);
useEffect(() => {
if (!open || !initialThreadId) return;
@@ -124,7 +125,7 @@ export function InstructorChatPanel({ session, open, initialThreadId = null, ini
socket.off('chat.message.created', handleMessageCreated);
socket.disconnect();
};
}, [open, selectedThreadId, session.accessToken]);
}, [courseId, open, selectedThreadId, session.accessToken]);
useEffect(() => {
if (!open) setSelectedThreadId(null);