SSE
This commit is contained in:
@@ -6,7 +6,7 @@ import { z } from "zod";
|
||||
import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
||||
import brackets from "@/features/bracket/utils";
|
||||
import { Match, MatchInput } from "@/features/matches/types";
|
||||
import { serverEvents } from "@/lib/events/emitter";
|
||||
import { emitServerEvent } from "@/lib/events/emitter";
|
||||
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
|
||||
import { PlayerInfo } from "../players/types";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
@@ -129,6 +129,8 @@ export const generateTournamentBracket = createServerFn()
|
||||
matchCount: createdMatches.length,
|
||||
});
|
||||
|
||||
emitServerEvent({ type: "tournament", tournamentId });
|
||||
|
||||
return {
|
||||
tournament,
|
||||
matchCount: createdMatches.length,
|
||||
@@ -154,7 +156,7 @@ export const startMatch = createServerFn()
|
||||
status: "started",
|
||||
});
|
||||
|
||||
serverEvents.emit("match", {
|
||||
emitServerEvent({
|
||||
type: "match",
|
||||
matchId: match.id,
|
||||
tournamentId: match.tournament.id
|
||||
@@ -180,7 +182,9 @@ export const populateKnockoutBracket = createServerFn()
|
||||
throw new Error("Tournament must have group_config");
|
||||
}
|
||||
|
||||
return await populateKnockoutBracketInternal(tournamentId, tournament.group_config);
|
||||
const result = await populateKnockoutBracketInternal(tournamentId, tournament.group_config);
|
||||
emitServerEvent({ type: "tournament", tournamentId });
|
||||
return result;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -479,7 +483,7 @@ export const endMatch = createServerFn()
|
||||
});
|
||||
|
||||
if (match.lid === -1) {
|
||||
serverEvents.emit("match", {
|
||||
emitServerEvent({
|
||||
type: "match",
|
||||
matchId: match.id,
|
||||
tournamentId: match.tournament.id
|
||||
@@ -504,6 +508,11 @@ export const endMatch = createServerFn()
|
||||
});
|
||||
|
||||
await pbAdmin.deleteMatch(winner.id);
|
||||
emitServerEvent({
|
||||
type: "match",
|
||||
matchId: match.id,
|
||||
tournamentId: match.tournament.id
|
||||
});
|
||||
return match;
|
||||
}
|
||||
}
|
||||
@@ -530,7 +539,7 @@ export const endMatch = createServerFn()
|
||||
});
|
||||
}
|
||||
|
||||
serverEvents.emit("match", {
|
||||
emitServerEvent({
|
||||
type: "match",
|
||||
matchId: match.id,
|
||||
tournamentId: match.tournament.id
|
||||
@@ -590,7 +599,7 @@ export const toggleMatchReaction = createServerFn()
|
||||
|
||||
const reactions = Object.values(reactionsByEmoji);
|
||||
|
||||
serverEvents.emit("reaction", {
|
||||
emitServerEvent({
|
||||
type: "reaction",
|
||||
matchId,
|
||||
reactions,
|
||||
|
||||
Reference in New Issue
Block a user