Fix poker:leave regression: move leave emit from PokerRoom to Room level
All checks were successful
Build & Push Container Image / build (push) Successful in 9s
All checks were successful
Build & Push Container Image / build (push) Successful in 9s
poker:leave was firing on every issue advance (PokerRoom unmount), causing a race condition where participants were briefly removed and revealIfComplete triggered after just 1 vote. Now poker:leave only emits when the user truly leaves the room (Room component unmounts). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3051119405
commit
062510b6c6
2 changed files with 15 additions and 2 deletions
|
|
@ -80,7 +80,6 @@ export default function PokerRoom({ session, issue, user, onSaved }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.emit('poker:leave', { sessionId: session.id });
|
|
||||||
socket.off('poker:participants', onParticipants);
|
socket.off('poker:participants', onParticipants);
|
||||||
socket.off('poker:vote-update', onVoteUpdate);
|
socket.off('poker:vote-update', onVoteUpdate);
|
||||||
socket.off('poker:revealed', onRevealed);
|
socket.off('poker:revealed', onRevealed);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { api } from '../services/api';
|
import { api } from '../services/api';
|
||||||
|
import { getSocket } from '../services/socket';
|
||||||
import PokerRoom from './PokerRoom';
|
import PokerRoom from './PokerRoom';
|
||||||
import DarkModeToggle from './DarkModeToggle';
|
import DarkModeToggle from './DarkModeToggle';
|
||||||
import AdfRenderer from './AdfRenderer';
|
import AdfRenderer from './AdfRenderer';
|
||||||
|
|
@ -13,6 +14,18 @@ export default function Room({ room, user, dark, toggleDark, onBack }) {
|
||||||
const issuesRef = useRef([]);
|
const issuesRef = useRef([]);
|
||||||
|
|
||||||
const pokerUser = { key: user.jiraAccountId, name: user.displayName };
|
const pokerUser = { key: user.jiraAccountId, name: user.displayName };
|
||||||
|
const socket = useMemo(() => getSocket(), []);
|
||||||
|
const activeSessionIdRef = useRef(null);
|
||||||
|
|
||||||
|
// Emit poker:leave when the Room unmounts (user truly leaves the room)
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
const sessionId = activeSessionIdRef.current;
|
||||||
|
if (sessionId) {
|
||||||
|
socket.emit('poker:leave', { sessionId });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [socket]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadIssues();
|
loadIssues();
|
||||||
|
|
@ -69,6 +82,7 @@ export default function Room({ room, user, dark, toggleDark, onBack }) {
|
||||||
|
|
||||||
const activeSessionRef = useRef(null);
|
const activeSessionRef = useRef(null);
|
||||||
activeSessionRef.current = activeSession;
|
activeSessionRef.current = activeSession;
|
||||||
|
activeSessionIdRef.current = activeSession?.session?.id || null;
|
||||||
|
|
||||||
const advanceToNext = useCallback((estimate) => {
|
const advanceToNext = useCallback((estimate) => {
|
||||||
if (!activeSessionRef.current) return;
|
if (!activeSessionRef.current) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue