diff --git a/src/lib/chessCom.ts b/src/lib/chessCom.ts index d73ece0..e0b578f 100644 --- a/src/lib/chessCom.ts +++ b/src/lib/chessCom.ts @@ -19,7 +19,7 @@ export const getUserRecentGames = async ( const games: ChessComGame[] = data?.games ?? []; - if (games.length < 20) { + if (games.length < 50) { const previousMonth = month === 1 ? 12 : month - 1; const previousPaddedMonth = getPaddedMonth(previousMonth); const yearToFetch = previousMonth === 12 ? year - 1 : year; @@ -33,9 +33,9 @@ export const getUserRecentGames = async ( games.push(...(dataPreviousMonth?.games ?? [])); } - games.sort((a, b) => { + const gamesToReturn = games.slice(0, 50).sort((a, b) => { return b.end_time - a.end_time; }); - return games; + return gamesToReturn; }; diff --git a/src/sections/loadGame/chessComInput.tsx b/src/sections/loadGame/chessComInput.tsx index 622fa56..39f6a51 100644 --- a/src/sections/loadGame/chessComInput.tsx +++ b/src/sections/loadGame/chessComInput.tsx @@ -47,7 +47,7 @@ export default function ChessComInput({ pgn, setPgn }: Props) { return ( <> - + - - {games.map((game) => ( - setPgn(game.pgn)} - selected={pgn === game.pgn} - style={{ width: 350, maxWidth: 350 }} - key={game.uuid} - > - - - ))} - + {games.length > 0 && ( + + {games.map((game) => ( + setPgn(game.pgn)} + selected={pgn === game.pgn} + style={{ width: 350, maxWidth: 350 }} + key={game.uuid} + > + + + ))} + + )} ); }