franciscoBSalgueiro / en-croissant

The Ultimate Chess Toolkit
https://encroissant.org
GNU General Public License v3.0
653 stars 82 forks source link

When importing Lichess accounts with no games, It will show NaN% Downloaded. #336

Open TheOddCell opened 3 months ago

TheOddCell commented 3 months ago

Describe the bug

When you use a Lichess (not tested with chess.com, used browser sign-in) account with NO GAMES PLAYED, it will show NaN% as the download persentage. image image

Reproduction

  1. Go to the Accounts tab
  2. Add a Lichess account with browser sign-in THAT HAS NO GAMES PLAYED. Not tested with Chess.com, or without browser sign-in.
  3. Reload and Download the database
  4. Check the download persentage

Platform and versions

Windows 11 Pro 23E2 Build 22631.3958, Version: 0.10.0 Tauri version: 1.6.1

Stack trace

No response

zanciks commented 3 months ago

Seems like a simple fix. en-croissant/src/components/home/AccountCard.tsx line 144 const percentage = ((downloadedGames / total) * 100).toFixed(2);. Just need to add an if statement for if total is 0. What would the expected result be here though? 100%? 0%? I can add in the fix if anybody has thoughts on what the expected result should be?