Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small PR: some fixes #855

Merged
merged 4 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rcongui_public/src/components/game/statistics/game-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function DataTable<TData extends Player, TValue, TExtraColumnId extends s

return (
<div className="border w-full divide-y">
<div className="flex flex-row justify-between items-start p-2 flex-wrap gap-3">
<div className="flex flex-row justify-between items-start p-2 gap-3">
<div className="flex flex-row items-start gap-3">
{hasIsOnline && (
<Select onValueChange={(value) => table.getColumn('is_online')?.setFilterValue(value)}>
Expand All @@ -132,7 +132,7 @@ export function DataTable<TData extends Player, TValue, TExtraColumnId extends s
</div>
</SelectItem>
{teamOptions.map((option, index) =>
<SelectItem value={option}>
<SelectItem key={option} value={option}>
<div className="flex">
<TeamIndicator team={option as TeamEnum} className="block m-auto" />
<div className="pl-3">{t(option)} ({teamCounts[index]})</div>
Expand Down Expand Up @@ -177,7 +177,7 @@ export function DataTable<TData extends Player, TValue, TExtraColumnId extends s
</PlainSelectTrigger>
<SelectContent className={'px-4 py-2 pl-2'}>
{extraColumns.map((column) => (
<div>
<div key={column.id}>
<Checkbox
value={column.id}
checked={column.displayed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function WeaponTypeBar({ player }: WeaponTypeBarProps) {
</TooltipTrigger>
<TooltipContent>
{Object.entries(simpleWeaponTypeMap).map(([_, props]) =>
<div className="flex items-center">
<div className="flex items-center" key={props.t}>
<span className="w-4 size-2" style={{background: props.color}}/>
<span className="ml-2">{props.t}</span>
</div>
Expand Down
1 change: 1 addition & 0 deletions rcongui_public/src/components/header/nav-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function NavLinks() {
const isNotActive = pathname.pathname !== link.href
return (
<Button
key={link.href}
variant={'text'}
className={cn(
'text-sm font-medium transition-colors focus:ring-primary',
Expand Down
11 changes: 5 additions & 6 deletions rcongui_public/src/pages/games/horizontal-games-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,15 @@ export const HorizontalGamesList = ({ games }: { games: ScoreboardMaps }) => {
<ScrollArea ref={scrollAreaRef} className="w-full whitespace-nowrap sm:-mx-4 xl:mx-0 pb-2 relative overflow-hidden z-auto">
<div className="flex flex-row w-max">
{validGames.map((game, index) => (
<>
<div ref={(element: any) => {
<React.Fragment key={game.id}>
<div key={game.id} ref={(element: any) => {
if (element) {
gameBoundingRefs.current.set(index, element);
} else {
gameBoundingRefs.current.delete(index);
}
}}>
<GameCard
key={game.id}
game={game}
pathname={pathname}
onMouseEnter={() => setHoverGameDate(game.start)}
Expand All @@ -116,24 +115,24 @@ export const HorizontalGamesList = ({ games }: { games: ScoreboardMaps }) => {
{!dayjsLocal(game.start).isSame(dayjsLocal(validGames[index + 1]?.start), 'day') &&
<>
<DateCard
zIndex={validGames.length - index}
key={game.start}
zIndex={validGames.length - index}
dateString={game.start}
highlight={!!hoverGameDate && dayjsLocal(hoverGameDate).isSame(dayjsLocal(game.start), 'day')}
sticky={false}
/>
{!!stickyDate && stickyDate.isSame(dayjsLocal(game.start), 'day') &&
<DateCard
zIndex={validGames.length - index}
key={`sticky-${game.start}`}
zIndex={validGames.length - index}
dateString={game.start}
sticky={true}
highlight={!!hoverGameDate && dayjsLocal(hoverGameDate).isSame(dayjsLocal(game.start), 'day')}
/>
}
</>
}
</>
</React.Fragment>
))}
</div>
<ScrollBar orientation="horizontal"/>
Expand Down
2 changes: 1 addition & 1 deletion rcongui_public/src/pages/games/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function GamesLayout() {
onReset={reset}
>
<Suspense fallback={<div>Loading...</div>}>
<HorizontalGamesList games={games}/>
<HorizontalGamesList games={games} key={`${games.maps[0].id}-${games.maps[games.maps.length - 1].id}`}/>
</Suspense>
</ErrorBoundary>
)}
Expand Down
10 changes: 9 additions & 1 deletion rcongui_public/src/pages/games/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ import { columns } from './columns'
import { DataTable as MatchTable } from './table'
import MatchPagination from './pagination'
import { ScoreboardMap, ScoreboardMaps } from '@/types/api'
import {GameMode} from "@/types/mapLayer";

export function validGame(game: ScoreboardMap) {
const modeToTime: Record<GameMode, number> = {
['warfare']: 90,
['offensive']: 150,
['skirmish']: 30,
['control']: 30,
}

const start = dayjs(game.start)
const end = dayjs(game.end)
const diffMinutes = end.diff(start, 'minutes')
const isDraw = (game.result?.allied ?? 0) + (game.result?.axis ?? 0) === 4

return diffMinutes < 100 && diffMinutes > 9 && !isDraw
return diffMinutes < (modeToTime[game.map.game_mode] ?? 90) + 10 && diffMinutes > 9 && !isDraw
}

export default function GamesList({
Expand Down
Loading