Skip to content

Commit

Permalink
fix linter and react errors
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Sep 20, 2023
1 parent 2230aec commit 566675f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ pub async fn convert_pgn(
let event_count: i64 = events::table.count().get_result(db)?;
let site_count: i64 = sites::table.count().get_result(db)?;

let counts = vec![
let counts = [
("GameCount", game_count),
("PlayerCount", player_count),
("EventCount", event_count),
Expand Down
5 changes: 3 additions & 2 deletions src/components/panels/analysis/AnalysisPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ProgressButton from "@/components/common/ProgressButton";
import { TreeStateContext } from "@/components/common/TreeStateContext";
import BestMoves from "./BestMoves";
import EngineSelection from "./EngineSelection";
import React from "react";

const labels = {
action: "Generate report",
Expand Down Expand Up @@ -137,14 +138,14 @@ const GameStats = memo(
.map((annotation) => {
const s = annotation as "??" | "?" | "?!" | "!!" | "!" | "!?";
return (
<>
<React.Fragment key={annotation}>
<Grid.Col span={4} sx={{ textAlign: "center" }}>
{whiteAnnotations[s]}
</Grid.Col>
<Grid.Col span={1}>{annotation}</Grid.Col>
<Grid.Col span={4}>{ANNOTATION_INFO[s].name}</Grid.Col>
<Grid.Col span={2}>{blackAnnotations[s]}</Grid.Col>
</>
</React.Fragment>
);
})}
</Grid>
Expand Down
7 changes: 3 additions & 4 deletions src/components/panels/analysis/AnalysisRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Score } from "@/utils/score";
import MoveCell from "@/components/boards/MoveCell";
import { TreeDispatchContext } from "@/components/common/TreeStateContext";
import ScoreBubble from "./ScoreBubble";
import React from "react";

function AnalysisRow({
score,
Expand Down Expand Up @@ -42,14 +43,12 @@ function AnalysisRow({
const total_moves = halfMoves + index + 1 + (threat ? 1 : 0);
const is_white = total_moves % 2 === 1;
const move_number = Math.ceil(total_moves / 2);

return (
<>
<React.Fragment key={index + move}>
{(index === 0 || is_white) && (
<>{`${move_number.toString()}${is_white ? "." : "..."}`}</>
)}
<MoveCell
key={index + move}
move={move}
isCurrentVariation={false}
annotation={""}
Expand All @@ -64,7 +63,7 @@ function AnalysisRow({
}
}}
/>
</>
</React.Fragment>
);
})}
</Flex>
Expand Down
39 changes: 20 additions & 19 deletions src/components/panels/analysis/EngineSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,39 @@ import { Engine } from "@/utils/engines";
import ImageCheckbox from "./ImageCheckbox";
import { convertFileSrc } from "@tauri-apps/api/tauri";

function EngineBox(props: {
function EngineBox({
engine,
setEngines,
}: {
engine: Engine;
setEngines: React.Dispatch<React.SetStateAction<Engine[]>>;
}) {
const [imageSrc, setImageSrc] = useState<string | undefined>(undefined);

useEffect(() => {
(async () => {
if (props.engine.image.startsWith("http")) {
setImageSrc(props.engine.image);
} else if (props.engine.image) {
setImageSrc(await convertFileSrc(props.engine.image));
if (engine.image && engine.image.startsWith("http")) {
setImageSrc(engine.image);
} else if (engine.image) {
setImageSrc(await convertFileSrc(engine.image));
}
})();
}, [props.engine.image]);
}, [engine.image]);

return (
<Grid.Col span={4}>
{imageSrc && (
<ImageCheckbox
title={props.engine.name}
image={imageSrc}
checked={props.engine.loaded}
onChange={(checked) =>
props.setEngines((engines) =>
engines.map((e) =>
e.name === props.engine.name ? { ...e, loaded: checked } : e
)
<ImageCheckbox
title={engine.name}
image={imageSrc}
checked={engine.loaded}
onChange={(checked) =>
setEngines((engines) =>
engines.map((e) =>
e.name === engine.name ? { ...e, loaded: checked } : e
)
}
/>
)}
)
}
/>
</Grid.Col>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/panels/analysis/ImageCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface ImageCheckboxProps {
onChange?(checked: boolean): void;
title: string;
description?: string;
image: string;
image?: string;
}

export default function ImageCheckbox({
Expand Down
2 changes: 1 addition & 1 deletion src/utils/engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Engine {
name: string;
version: string;
path: string;
image: string;
image?: string;
elo: number | "";
downloadSize?: number;
downloadLink?: string;
Expand Down

0 comments on commit 566675f

Please sign in to comment.