From 06f1dc9d6aa4cb98eaf21dacb18eea3c95c057a4 Mon Sep 17 00:00:00 2001 From: gm-m Date: Sat, 14 Dec 2024 23:04:57 +0100 Subject: [PATCH] fix: import from pgn --- src/components/tabs/ImportModal.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/tabs/ImportModal.tsx b/src/components/tabs/ImportModal.tsx index f0e8b6f4..fff3556f 100644 --- a/src/components/tabs/ImportModal.tsx +++ b/src/components/tabs/ImportModal.tsx @@ -69,12 +69,13 @@ 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) { @@ -82,8 +83,13 @@ export default function ImportModal({ 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,