From 76e7570f5b19f14519133e7ad2d901111ddf40d7 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 20 Oct 2024 09:30:10 +0300 Subject: [PATCH] Clear tournament cache on sub post change to keep the number in tab in sync --- app/features/tournament-subs/routes/to.$id.subs.new.tsx | 7 ++++++- app/features/tournament-subs/routes/to.$id.subs.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/features/tournament-subs/routes/to.$id.subs.new.tsx b/app/features/tournament-subs/routes/to.$id.subs.new.tsx index ae2c398ef..57f605753 100644 --- a/app/features/tournament-subs/routes/to.$id.subs.new.tsx +++ b/app/features/tournament-subs/routes/to.$id.subs.new.tsx @@ -17,7 +17,10 @@ import { TrashIcon } from "~/components/icons/Trash"; import { useUser } from "~/features/auth/core/user"; import { requireUser } from "~/features/auth/core/user.server"; import { tournamentIdFromParams } from "~/features/tournament"; -import { tournamentFromDB } from "~/features/tournament-bracket/core/Tournament.server"; +import { + clearTournamentDataCache, + tournamentFromDB, +} from "~/features/tournament-bracket/core/Tournament.server"; import type { MainWeaponId } from "~/modules/in-game-lists"; import { type SendouRouteHandle, @@ -65,6 +68,8 @@ export const action: ActionFunction = async ({ params, request }) => { userId: user.id, }); + clearTournamentDataCache(tournamentId); + throw redirect(tournamentSubsPage(tournamentId)); }; diff --git a/app/features/tournament-subs/routes/to.$id.subs.tsx b/app/features/tournament-subs/routes/to.$id.subs.tsx index 1ce0a60fc..2e837f9a5 100644 --- a/app/features/tournament-subs/routes/to.$id.subs.tsx +++ b/app/features/tournament-subs/routes/to.$id.subs.tsx @@ -18,7 +18,10 @@ import { TrashIcon } from "~/components/icons/Trash"; import { useUser } from "~/features/auth/core/user"; import { getUser, requireUser } from "~/features/auth/core/user.server"; import { tournamentIdFromParams } from "~/features/tournament"; -import { tournamentFromDB } from "~/features/tournament-bracket/core/Tournament.server"; +import { + clearTournamentDataCache, + tournamentFromDB, +} from "~/features/tournament-bracket/core/Tournament.server"; import { useTournament } from "~/features/tournament/routes/to.$id"; import { parseRequestPayload, validate } from "~/utils/remix.server"; import { assertUnreachable } from "~/utils/types"; @@ -52,6 +55,8 @@ export const action: ActionFunction = async ({ request, params }) => { userId: data.userId, }); + clearTournamentDataCache(tournamentId); + return null; };