From 9bc03c27b90df8f8acfdecc5cfbcbf8226485abc Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 30 Mar 2022 11:39:44 +0200 Subject: [PATCH] prefer nickname sorting participants --- resources/js/helpers/Participant.js | 6 ++++-- resources/js/helpers/User.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index 7a68996..d7bdd7c 100644 --- a/resources/js/helpers/Participant.js +++ b/resources/js/helpers/Participant.js @@ -1,3 +1,5 @@ +import User from './User'; + export const compareFinished = round => (a, b) => { const a_result = findResult(a, round); const b_result = findResult(b, round); @@ -41,8 +43,8 @@ export const compareResult = round => (a, b) => { }; export const compareUsername = (a, b) => { - const a_name = a && a.user && a.user.username ? a.user.username : ''; - const b_name = b && b.user && b.user.username ? b.user.username : ''; + const a_name = a && a.user ? User.getUserName(a.user) : ''; + const b_name = b && b.user ? User.getUserName(b.user) : ''; return a_name.localeCompare(b_name); }; diff --git a/resources/js/helpers/User.js b/resources/js/helpers/User.js index 222e0f6..f13e119 100644 --- a/resources/js/helpers/User.js +++ b/resources/js/helpers/User.js @@ -18,5 +18,6 @@ export const hasFinishedRound = (user, round) => { export default { findResult, getAvatarUrl, + getUserName, hasFinishedRound, }; -- 2.39.2