From c123c8fb9a0056b29baf188f93c155570439e7ee Mon Sep 17 00:00:00 2001 From: Luca <55391576+brentspine@users.noreply.github.com> Date: Fri, 3 Jul 2026 16:37:00 +0200 Subject: [PATCH 1/2] fix(friends): Display issue for users with unfetchable test amount; Fixes #8189 (@brentspine) --- .../pages/connections/FriendsList.tsx | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/ts/components/pages/connections/FriendsList.tsx b/frontend/src/ts/components/pages/connections/FriendsList.tsx index b5a9dbb050a7..91b3975158d6 100644 --- a/frontend/src/ts/components/pages/connections/FriendsList.tsx +++ b/frontend/src/ts/components/pages/connections/FriendsList.tsx @@ -179,17 +179,29 @@ function getColumns({ defineColumn("completedTests", { enableSorting: true, header: "tests", - cell: (info) => `${info.getValue()}/${info.row.original.startedTests}`, + cell: (info) => { + const completedTests = info.getValue(); + const startedTests = info.row.original.startedTests; + + return completedTests === undefined || startedTests === undefined + ? "-" + : `${completedTests}/${startedTests}`; + }, meta: { breakpoint: "lg", cellMeta: ({ row }) => { + const completedTests = row.completedTests; + const startedTests = row.startedTests; + + if (completedTests === undefined || startedTests === undefined) { + return {}; + } + const testStats = formatTypingStatsRatio(row); - + return { "data-balloon-pos": "up", - "aria-label": `${testStats.completedPercentage}% (${ - testStats.restartRatio - } restarts per completed test)`, + "aria-label": `${testStats.completedPercentage}% (${testStats.restartRatio} restarts per completed test)`, }; }, }, From c308e9f47ade1e0fd88172ad7b646d2a365def45 Mon Sep 17 00:00:00 2001 From: Brentspine Date: Fri, 3 Jul 2026 18:26:05 +0200 Subject: [PATCH 2/2] fix(stats): 0-safety for test ratio (@brentspine) --- .../ts/components/pages/connections/FriendsList.tsx | 13 +++++-------- frontend/src/ts/utils/misc.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/frontend/src/ts/components/pages/connections/FriendsList.tsx b/frontend/src/ts/components/pages/connections/FriendsList.tsx index 91b3975158d6..5fc7490809fa 100644 --- a/frontend/src/ts/components/pages/connections/FriendsList.tsx +++ b/frontend/src/ts/components/pages/connections/FriendsList.tsx @@ -182,7 +182,7 @@ function getColumns({ cell: (info) => { const completedTests = info.getValue(); const startedTests = info.row.original.startedTests; - + return completedTests === undefined || startedTests === undefined ? "-" : `${completedTests}/${startedTests}`; @@ -190,15 +190,12 @@ function getColumns({ meta: { breakpoint: "lg", cellMeta: ({ row }) => { - const completedTests = row.completedTests; - const startedTests = row.startedTests; - - if (completedTests === undefined || startedTests === undefined) { + const testStats = formatTypingStatsRatio(row); + + if (testStats.completedPercentage === "") { return {}; } - - const testStats = formatTypingStatsRatio(row); - + return { "data-balloon-pos": "up", "aria-label": `${testStats.completedPercentage}% (${testStats.restartRatio} restarts per completed test)`, diff --git a/frontend/src/ts/utils/misc.ts b/frontend/src/ts/utils/misc.ts index 6480e38ae000..1cfd09126a47 100644 --- a/frontend/src/ts/utils/misc.ts +++ b/frontend/src/ts/utils/misc.ts @@ -726,10 +726,13 @@ export function formatTypingStatsRatio(stats: { completedPercentage: Math.floor( (stats.completedTests / stats.startedTests) * 100, ).toString(), - restartRatio: ( - (stats.startedTests - stats.completedTests) / - stats.completedTests - ).toFixed(1), + restartRatio: + stats.completedTests === 0 + ? "-" + : ( + (stats.startedTests - stats.completedTests) / + stats.completedTests + ).toFixed(1), }; }