diff --git a/app/features/sendouq/components/GroupCard.tsx b/app/features/sendouq/components/GroupCard.tsx index e1ade32bd..8bea40c26 100644 --- a/app/features/sendouq/components/GroupCard.tsx +++ b/app/features/sendouq/components/GroupCard.tsx @@ -17,7 +17,6 @@ import { useUser } from "~/features/auth/core/user"; import { MATCHES_COUNT_NEEDED_FOR_LEADERBOARD } from "~/features/leaderboards/leaderboards-constants"; import { ordinalToRoundedSp } from "~/features/mmr/mmr-utils"; import type { TieredSkill } from "~/features/mmr/tiered.server"; -import { useMainContentWidth } from "~/hooks/useMainContentWidth"; import { languagesUnified } from "~/modules/i18n/config"; import { SPLATTERCOLOR_SCREEN_ID } from "~/modules/in-game-lists/weapon-ids"; import { inGameNameWithoutDiscriminator } from "~/utils/strings"; @@ -34,11 +33,7 @@ import type { SQGroupMember, SQOwnGroup, } from "../core/SendouQ.server"; -import { - FULL_GROUP_SIZE, - IS_Q_LOOKING_MOBILE_BREAKPOINT, - SENDOUQ, -} from "../q-constants"; +import { FULL_GROUP_SIZE, SENDOUQ } from "../q-constants"; import { resolveFutureMatchModes } from "../q-utils"; import styles from "./GroupCard.module.css"; @@ -58,6 +53,7 @@ export function GroupCard({ showAddNote, showNote = false, ownGroup, + layout = "desktop", }: { group: SQGroup | SQOwnGroup; action?: "LIKE" | "UNLIKE" | "GROUP_UP" | "MATCH_UP" | "MATCH_UP_RECHALLENGE"; @@ -68,6 +64,7 @@ export function GroupCard({ showAddNote?: SqlBool; showNote?: boolean; ownGroup?: SQOwnGroup; + layout?: "mobile" | "desktop"; }) { const { t } = useTranslation(["q"]); const user = useUser(); @@ -88,7 +85,11 @@ export function GroupCard({ const enableKicking = group.usersRole === "OWNER" && !displayOnly; return ( - +
{group.members ? (
@@ -240,15 +241,14 @@ export function GroupCard({ function GroupCardContainer({ isOwnGroup, groupId, + layout, children, }: { isOwnGroup: boolean; groupId: number; + layout: "mobile" | "desktop"; children: React.ReactNode; }) { - const width = useMainContentWidth(); - const layout = width < IS_Q_LOOKING_MOBILE_BREAKPOINT ? "mobile" : "desktop"; - // we don't want it to animate if (isOwnGroup) return <>{children}; diff --git a/app/features/sendouq/routes/q.looking.tsx b/app/features/sendouq/routes/q.looking.tsx index a7ab4e48d..fde36a96a 100644 --- a/app/features/sendouq/routes/q.looking.tsx +++ b/app/features/sendouq/routes/q.looking.tsx @@ -229,15 +229,19 @@ function Groups() { const width = useMainContentWidth(); - if (!isHydrated) return null; + // width === 0 means the main content hasn't been measured yet; rendering the + // Flipper before measurement makes it snapshot the width-0 (mobile) default + // layout and then morph every card into the real layout on first navigation + if (!isHydrated || width === 0) return null; const isMobile = width < IS_Q_LOOKING_MOBILE_BREAKPOINT; + const layout = isMobile ? "mobile" : "desktop"; const isFullGroup = data.ownGroup && data.ownGroup.members.length === FULL_GROUP_SIZE; const invitedGroupsDesktop = (
- + {t( isFullGroup ? "q:looking.columns.challenged" @@ -256,6 +260,7 @@ function Groups() { action="UNLIKE" showNote ownGroup={data.ownGroup} + layout={layout} /> ); })} @@ -264,7 +269,9 @@ function Groups() { const ownGroupElement = data.ownGroup ? (
- {t("q:looking.columns.myGroup")} + + {t("q:looking.columns.myGroup")} + {data.ownGroup.inviteCode ? (
- {t("q:looking.columns.available")} + + {t("q:looking.columns.available")} + {(isMobile ? data.groups.filter( (group) => @@ -353,6 +362,7 @@ function Groups() { } showNote ownGroup={data.ownGroup} + layout={layout} /> ); })} @@ -380,6 +390,7 @@ function Groups() { action={action()} showNote ownGroup={data.ownGroup} + layout={layout} /> ); })} @@ -390,7 +401,7 @@ function Groups() {
{!isMobile ? (
- + {t( isFullGroup ? "q:looking.columns.challenges" @@ -417,6 +428,7 @@ function Groups() { action={action()} showNote ownGroup={data.ownGroup} + layout={layout} /> ); })} @@ -427,11 +439,13 @@ function Groups() { ); } -function ColumnHeader({ children }: { children: React.ReactNode }) { - const width = useMainContentWidth(); - - const isMobile = width < IS_Q_LOOKING_MOBILE_BREAKPOINT; - +function ColumnHeader({ + isMobile, + children, +}: { + isMobile: boolean; + children: React.ReactNode; +}) { if (isMobile) return null; return
{children}
;