teamsbot: SSE-Stream verbindet beim ersten Laden (sessionStatus in deps)
Made-with: Cursor
This commit is contained in:
parent
44f1e1a498
commit
d5a4c880a4
1 changed files with 4 additions and 3 deletions
|
|
@ -85,9 +85,10 @@ export const TeamsbotSessionView: React.FC = () => {
|
||||||
|
|
||||||
// SSE Live Stream - connect once per session, don't re-create on status changes
|
// SSE Live Stream - connect once per session, don't re-create on status changes
|
||||||
const sseSessionRef = useRef<string | null>(null);
|
const sseSessionRef = useRef<string | null>(null);
|
||||||
|
const sessionStatus = session?.status;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!instanceId || !sessionId || !session) return;
|
if (!instanceId || !sessionId || !sessionStatus) return;
|
||||||
if (!['active', 'joining', 'pending'].includes(session.status)) return;
|
if (!['active', 'joining', 'pending'].includes(sessionStatus)) return;
|
||||||
// Avoid reconnecting if already streaming this session
|
// Avoid reconnecting if already streaming this session
|
||||||
if (sseSessionRef.current === sessionId && eventSourceRef.current) return;
|
if (sseSessionRef.current === sessionId && eventSourceRef.current) return;
|
||||||
|
|
||||||
|
|
@ -168,7 +169,7 @@ export const TeamsbotSessionView: React.FC = () => {
|
||||||
sseSessionRef.current = null;
|
sseSessionRef.current = null;
|
||||||
setIsLive(false);
|
setIsLive(false);
|
||||||
};
|
};
|
||||||
}, [instanceId, sessionId]);
|
}, [instanceId, sessionId, sessionStatus]);
|
||||||
|
|
||||||
// Polling fallback: refresh session data every 5s when SSE is not connected
|
// Polling fallback: refresh session data every 5s when SSE is not connected
|
||||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue