From 7f2ab710e52f9e37b798423143fc687da1e00783 Mon Sep 17 00:00:00 2001 From: S-N-O-R-L-A-X Date: Sat, 23 Dec 2023 13:50:04 +0800 Subject: [PATCH] fix: show wrong statistics when input new board length --- src/views/Analysis/Analysis.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/views/Analysis/Analysis.tsx b/src/views/Analysis/Analysis.tsx index dcf6e8a..7608122 100644 --- a/src/views/Analysis/Analysis.tsx +++ b/src/views/Analysis/Analysis.tsx @@ -29,16 +29,18 @@ export default function Analysis() { async function countTricks() { for (const board of all_boards) { if (!board.ddtricks) { - board.ddtricks = await analyzeOffline(board.board) + board.ddtricks = await analyzeOffline(board.board); } MatrixAdd(table, board.ddtricks as (string | number)[][]); } - - setTable(MatrixDivide(table,all_boards.length||1)); + return Promise.resolve(); } - countTricks(); - - }, [all_boards]) + countTricks().then(()=>{ + if (all_boards.length > 0) { + setTable(MatrixDivide(table, all_boards.length)); + } + }) + }, [all_boards.length]) return ( <>