feat: add socket event for participant removal from queues

This commit is contained in:
Chris Parsons 2025-10-24 21:46:55 -07:00
parent e7baea319e
commit 190dfb92ca
5 changed files with 40 additions and 0 deletions

View file

@ -160,6 +160,16 @@ export async function action(args: any) {
) )
); );
// Notify all clients that this participant was removed from queues
try {
const io = (global as any).__socketIO;
io.to(`draft-${seasonId}`).emit("participant-removed-from-queues", {
participantId: participantToPick.id,
});
} catch (error) {
console.error("Socket.IO participant-removed-from-queues error:", error);
}
// Emit socket event // Emit socket event
try { try {
const io = (global as any).__socketIO; const io = (global as any).__socketIO;

View file

@ -186,6 +186,16 @@ export async function action(args: any) {
) )
); );
// Notify all clients that this participant was removed from queues
try {
const io = (global as any).__socketIO;
io.to(`draft-${seasonId}`).emit("participant-removed-from-queues", {
participantId,
});
} catch (error) {
console.error("Socket.IO participant-removed-from-queues error:", error);
}
// Emit socket event // Emit socket event
try { try {
const io = (global as any).__socketIO; const io = (global as any).__socketIO;

View file

@ -151,6 +151,16 @@ export async function action(args: any) {
) )
); );
// Notify all clients that this participant was removed from queues
try {
const io = (global as any).__socketIO;
io.to(`draft-${seasonId}`).emit("participant-removed-from-queues", {
participantId,
});
} catch (error) {
console.error("Socket.IO participant-removed-from-queues error:", error);
}
// Add increment to the team that just picked // Add increment to the team that just picked
const currentTimer = await db.query.draftTimers.findFirst({ const currentTimer = await db.query.draftTimers.findFirst({
where: and( where: and(

View file

@ -406,6 +406,13 @@ export default function DraftRoom() {
setConnectedTeams(new Set(data.teamIds)); setConnectedTeams(new Set(data.teamIds));
}; };
const handleParticipantRemovedFromQueues = (data: { participantId: string }) => {
console.log("Participant removed from queues:", data.participantId);
setQueue((prev: any) =>
prev.filter((item: any) => item.participantId !== data.participantId)
);
};
on("pick-made", handlePickMade); on("pick-made", handlePickMade);
on("timer-update", handleTimerUpdate); on("timer-update", handleTimerUpdate);
on("draft-paused", handleDraftPaused); on("draft-paused", handleDraftPaused);
@ -415,6 +422,7 @@ export default function DraftRoom() {
on("team-connected", handleTeamConnected); on("team-connected", handleTeamConnected);
on("team-disconnected", handleTeamDisconnected); on("team-disconnected", handleTeamDisconnected);
on("connected-teams-list", handleConnectedTeamsList); on("connected-teams-list", handleConnectedTeamsList);
on("participant-removed-from-queues", handleParticipantRemovedFromQueues);
return () => { return () => {
off("pick-made", handlePickMade); off("pick-made", handlePickMade);
@ -426,6 +434,7 @@ export default function DraftRoom() {
off("team-connected", handleTeamConnected); off("team-connected", handleTeamConnected);
off("team-disconnected", handleTeamDisconnected); off("team-disconnected", handleTeamDisconnected);
off("connected-teams-list", handleConnectedTeamsList); off("connected-teams-list", handleConnectedTeamsList);
off("participant-removed-from-queues", handleParticipantRemovedFromQueues);
}; };
}, [on, off, currentPick, userTeam]); }, [on, off, currentPick, userTeam]);

View file

@ -28,6 +28,7 @@ interface ServerToClientEvents {
"connected-teams-list": (data: { teamIds: string[] }) => void; "connected-teams-list": (data: { teamIds: string[] }) => void;
"draft-paused": () => void; "draft-paused": () => void;
"draft-resumed": () => void; "draft-resumed": () => void;
"participant-removed-from-queues": (data: { participantId: string }) => void;
} }
interface ClientToServerEvents { interface ClientToServerEvents {