From 3ad9cbaaeef7d5954d8a220fb1a915644636b1bd Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 20 Mar 2022 21:00:14 +0200 Subject: [PATCH] isTestUser --- app/routes/play/looking.tsx | 6 ++++-- app/routes/play/match.$id.tsx | 23 +++++++++++++---------- app/utils/index.ts | 8 ++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/routes/play/looking.tsx b/app/routes/play/looking.tsx index 6549f3dc9..5fc2318bf 100644 --- a/app/routes/play/looking.tsx +++ b/app/routes/play/looking.tsx @@ -27,11 +27,12 @@ import { uniteGroupInfo, } from "~/core/play/utils"; import { canUniteWithGroup, isGroupAdmin } from "~/core/play/validators"; -import { usePolling } from "~/hooks/common"; +import { usePolling, useUser } from "~/hooks/common"; import * as LFGGroup from "~/models/LFGGroup.server"; import * as LFGMatch from "~/models/LFGMatch.server"; import styles from "~/styles/play-looking.css"; import { + isTestUser, makeTitle, parseRequestFormData, requireUser, @@ -326,6 +327,7 @@ export default function LookingPage() { const isPolling = !lookingOver(data.type, data.ownGroup); const lastUpdated = usePolling(isPolling); + const user = useUser(); if (lookingOver(data.type, data.ownGroup)) { return ; @@ -367,7 +369,7 @@ export default function LookingPage() { invariant(data.ownGroup.members, "!data.ownGroup.members"); return ( <> - {data.ownGroup.members.length > 1 && ( + {data.ownGroup.members.length > 1 && isTestUser(user?.id) && ( - {data.isOwnMatch && matchStartedInTheLastHour() && ( - g.members) - .flatMap((m) => (m.friendCode ? [[m.id, m.friendCode]] : [])) - )} - /> - )} + {data.isOwnMatch && + matchStartedInTheLastHour() && + isTestUser(user?.id) && ( + g.members) + .flatMap((m) => (m.friendCode ? [[m.id, m.friendCode]] : [])) + )} + /> + )}
{actionData?.error === "DIFFERENT_SCORE" && (
diff --git a/app/utils/index.ts b/app/utils/index.ts index 9dbc9c6cd..f3293cf29 100644 --- a/app/utils/index.ts +++ b/app/utils/index.ts @@ -3,6 +3,7 @@ import type { CSSProperties } from "react"; import { json, useLocation } from "remix"; import type { EventTargetRecorder } from "server/events"; import { z } from "zod"; +import { ADMIN_UUID } from "~/constants"; import { LoggedInUserSchema } from "~/utils/schemas"; export function flipObject< @@ -56,6 +57,13 @@ export function requireEvents(ctx: unknown) { } } +export function isTestUser(userId?: string) { + // latter is N-ZAP + return ( + userId === ADMIN_UUID || userId === "6cd9d01d-b724-498a-b706-eb70edd8a773" + ); +} + // https://stackoverflow.com/a/57888548 export function fetchTimeout(url: string, ms: number, options: RequestInit) { const controller = new AbortController();