From 0bd5ee5bb2a94863277b7d8ec08d9f8af3c7e0cc Mon Sep 17 00:00:00 2001 From: "arrz.dev" <55147716+arrzdev@users.noreply.github.com> Date: Mon, 2 Nov 2026 01:44:08 +0000 Subject: [PATCH] fix(game): settle the recent opponent chips once, clear the copied-check timer, name chips by player only --- .../components/online/invite-link-card.tsx | 12 +++- .../components/online/recent-opponents.tsx | 3 + apps/game/src/hooks/use-online-home.ts | 32 +++++---- apps/game/src/utils/recent-opponents.test.ts | 65 ++++++++++++++++++- apps/game/src/utils/recent-opponents.ts | 31 +++++++++ e2e/invite-composer.spec.ts | 14 +++- 6 files changed, 138 insertions(+), 19 deletions(-) diff --git a/apps/game/src/components/online/invite-link-card.tsx b/apps/game/src/components/online/invite-link-card.tsx index cf70180..cd3c58c 100644 --- a/apps/game/src/components/online/invite-link-card.tsx +++ b/apps/game/src/components/online/invite-link-card.tsx @@ -1,6 +1,6 @@ import { cn } from "@repo/nativ/utils" import { useMutation } from "@tanstack/react-query" -import { useId, useState } from "react" +import { useEffect, useId, useRef, useState } from "react" import { useTranslation } from "react-i18next" import { CheckIcon, @@ -55,6 +55,10 @@ export function InviteLinkCard({ const [status, setStatus] = useState("idle") const [justCopied, setJustCopied] = useState(false) const [canShare] = useState(canShareLinks) + const copiedTimer = useRef(undefined) + + //the check outlives the tap by two seconds, and the sheet may not + useEffect(() => () => window.clearTimeout(copiedTimer.current), []) const url = create.data?.url const isMade = Boolean(url) @@ -75,7 +79,11 @@ export function InviteLinkCard({ setStatus(next) if (next !== "copied") return setJustCopied(true) - window.setTimeout(() => setJustCopied(false), COPIED_MS) + window.clearTimeout(copiedTimer.current) + copiedTimer.current = window.setTimeout( + () => setJustCopied(false), + COPIED_MS, + ) } async function handleShare() { diff --git a/apps/game/src/components/online/recent-opponents.tsx b/apps/game/src/components/online/recent-opponents.tsx index fe699ff..0146d0f 100644 --- a/apps/game/src/components/online/recent-opponents.tsx +++ b/apps/game/src/components/online/recent-opponents.tsx @@ -126,7 +126,10 @@ function OpponentChip({ className="peer absolute inset-0 z-10 size-full cursor-[inherit] appearance-none rounded-xl opacity-0" /> + {/* The face is for the eye: its initial read first would put a stray + letter in front of the name in the chip's accessible name. */}