Skip to content

Commit

Permalink
fix: import from pgn
Browse files Browse the repository at this point in the history
  • Loading branch information
gm-m committed Dec 14, 2024
1 parent d439bd8 commit 06f1dc9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/tabs/ImportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,27 @@ export default function ImportModal({
let input = pgn;
if (file) {
const count = unwrap(await commands.countPgnGames(file));
input = unwrap(await commands.readGames(file, 0, 0))[0];
if (save) {
const games = unwrap(await commands.readGames(file, 0, count - 1));
input = games[0];
const newFile = await createFile({
filename,
filetype,
pgn: input,
pgn: games.join(""),
dir: documentDir,
});
if (newFile.isErr) {
setError(newFile.error.message);
setLoading(false);
return;
}
fileInfo = newFile.value;
fileInfo = {
...newFile.value,
numGames: count,
path: file,
};
} else {
input = unwrap(await commands.readGames(file, 0, 0))[0];
fileInfo = {
type: "file",
path: file,
Expand Down

0 comments on commit 06f1dc9

Please sign in to comment.