From d69ee21c1c5d246809803256a4b09c1744ab64d8 Mon Sep 17 00:00:00 2001 From: Pavel Drankov Date: Sun, 24 Sep 2023 20:14:41 +0300 Subject: [PATCH] releasef fix the error with infinity --- frontend/src/components/Profile/Alts.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Profile/Alts.jsx b/frontend/src/components/Profile/Alts.jsx index 913136b7..4d350c27 100644 --- a/frontend/src/components/Profile/Alts.jsx +++ b/frontend/src/components/Profile/Alts.jsx @@ -40,6 +40,9 @@ const Alts = ({ isMobile, alts }) => { }; const renderNumber = (number) => { + if(number === undefined) { + number = 0; + } let color = ratingToColor(number); return {number}; }; @@ -59,7 +62,10 @@ const Alts = ({ isMobile, alts }) => { console.error("Unknown bracket: " + bracket); } let found = (alt?.brackets ?? []).filter(findQuery); - let max = Math.max(...found.map((bracket) => bracket.rating)); + let max = 0; + if(found.length > 0) { + max = Math.max(...found.map((bracket) => bracket.rating)); + } return renderNumber(max); }; @@ -118,6 +124,11 @@ const Alts = ({ isMobile, alts }) => { alt[bracket.bracket_type] = bracket.rating; } }); + ["SHUFFLE", "ARENA_2v2", "ARENA_3v3", "BATTLEGROUNDS"].forEach((bracket) => { + if(alt[bracket] === undefined) { + alt[bracket] = 0; + } + }); return alt; });