Skip to content

Commit

Permalink
Don't show the "show all" button if the log is small
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpjones committed Feb 3, 2024
1 parent 77f8747 commit 2984d4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/views/ReportsCenter/ReportedGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import { socket } from "sockets";
import { Player } from "Player";
import { useUser } from "hooks";

const TRUNCATED_GAME_LOG_LENGTH = 25;

export function ReportedGame({
game_id,
reported_at,
Expand Down Expand Up @@ -309,7 +311,10 @@ function GameLog({ goban }: { goban: Goban }): JSX.Element {
</thead>
<tbody>
{log
.filter((_, idx) => shouldDisplayFullLog || idx < 25)
.filter(
(_, idx) =>
shouldDisplayFullLog || idx < TRUNCATED_GAME_LOG_LENGTH,
)
.map((entry, idx) => (
<tr key={entry.timestamp + ":" + idx} className="entry">
<td className="timestamp">
Expand All @@ -328,7 +333,7 @@ function GameLog({ goban }: { goban: Goban }): JSX.Element {
))}
</tbody>
</table>
{!shouldDisplayFullLog && (
{!shouldDisplayFullLog && log.length > TRUNCATED_GAME_LOG_LENGTH && (
<button onClick={() => setShouldDisplayFullLog(true)}>
{`${_("Show all")} (${log.length})`}
</button>
Expand Down

0 comments on commit 2984d4f

Please sign in to comment.