From 72523d7900d727702f3f2e73fba491e691616dcd Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:23:57 +0300 Subject: [PATCH] Show message when failing to join a team via link because already in group --- app/features/sendouq/routes/q.looking.tsx | 10 +++++++++- app/features/sendouq/routes/q.tsx | 9 +++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/features/sendouq/routes/q.looking.tsx b/app/features/sendouq/routes/q.looking.tsx index e58cf19f4..6bcd2d4c7 100644 --- a/app/features/sendouq/routes/q.looking.tsx +++ b/app/features/sendouq/routes/q.looking.tsx @@ -5,7 +5,7 @@ import type { V2_MetaFunction, } from "@remix-run/node"; import { redirect } from "@remix-run/node"; -import { useFetcher, useLoaderData } from "@remix-run/react"; +import { useFetcher, useLoaderData, useSearchParams } from "@remix-run/react"; import clsx from "clsx"; import * as React from "react"; import { Flipper } from "react-flip-toolkit"; @@ -352,10 +352,13 @@ export const loader = async ({ request }: LoaderArgs) => { export default function QLookingPage() { const data = useLoaderData(); + const [searchParams] = useSearchParams(); useAutoRefresh(); const ownGroup = data.groups.own as LookingGroupWithInviteCode; + const wasTryingToJoinAnotherTeam = searchParams.get("joining") === "true"; + return (
@@ -375,6 +378,11 @@ export default function QLookingPage() { trustedPlayers={data.trustedPlayers} /> ) : null} + {wasTryingToJoinAnotherTeam ? ( +
+ Before joining another group, leave the current one +
+ ) : null}
); diff --git a/app/features/sendouq/routes/q.tsx b/app/features/sendouq/routes/q.tsx index 3d40187e6..c5ec1e4fc 100644 --- a/app/features/sendouq/routes/q.tsx +++ b/app/features/sendouq/routes/q.tsx @@ -185,18 +185,19 @@ export const action: ActionFunction = async ({ request }) => { export const loader = async ({ request }: LoaderArgs) => { const user = await getUserId(request); + const code = new URL(request.url).searchParams.get( + JOIN_CODE_SEARCH_PARAM_KEY + ); + const redirectLocation = groupRedirectLocationByCurrentLocation({ group: user ? findCurrentGroupByUserId(user.id) : undefined, currentLocation: "default", }); if (redirectLocation) { - throw redirect(redirectLocation); + throw redirect(`${redirectLocation}${code ? "?joining=true" : ""}`); } - const code = new URL(request.url).searchParams.get( - JOIN_CODE_SEARCH_PARAM_KEY - ); const teamInvitedTo = code && user ? findTeamByInviteCode(code) : undefined; const now = new Date();