From 3cf9ea3bc3ba41204a22dc28dd303c70908c6f86 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Mon, 6 Feb 2023 23:55:51 +0000 Subject: [PATCH] fix: i'm literally not even explaining this one it dedupes things in the session raise viewer i don't care anymore i have give up hope --- .../sessions/SessionRaiseBreakdown.tsx | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/client/src/components/sessions/SessionRaiseBreakdown.tsx b/client/src/components/sessions/SessionRaiseBreakdown.tsx index 3c8acb8c1..1170881e7 100644 --- a/client/src/components/sessions/SessionRaiseBreakdown.tsx +++ b/client/src/components/sessions/SessionRaiseBreakdown.tsx @@ -152,16 +152,37 @@ function SessionScoreStatBreakdown({ } if (scoreInfo.isNewScore || scoreInfo.deltas[metric] > 0) { - PartialArrayRecordAssign( - newEnums[metric], + // @ts-expect-error yeah this is fine pls + const enumValue = score.scoreData[metric] as string; + // @ts-expect-error yeah this is fine pls + const enumIndex = score.scoreData.enumIndexes[metric] as integer; - // @ts-expect-error yeah this is fine pls - score.scoreData[metric] as string, - { - score, - scoreInfo, + if (newEnums[metric][enumValue]) { + const alreadyInArray = newEnums[metric][enumValue].find( + (e) => e.score.scoreID === score.scoreID + ); + + if ( + alreadyInArray && + // @ts-expect-error not justifying this + alreadyInArray.score.scoreData.enumIndexes[enumValue] < enumIndex + ) { + alreadyInArray.score = score; + alreadyInArray.scoreInfo = scoreInfo; + } else { + newEnums[metric][enumValue].push({ + score, + scoreInfo, + }); } - ); + } else { + newEnums[metric][enumValue] = [ + { + score, + scoreInfo, + }, + ]; + } } } }