From 7b2d3bfaf77f7233fe7a00b6357fa26f2ee526b6 Mon Sep 17 00:00:00 2001 From: vdbhb59 <60728004+vdbhb59@users.noreply.github.com> Date: Sun, 8 Oct 2023 22:31:19 +0530 Subject: [PATCH] Sort list of external players (FreeTubeApp#4036) Sort list of external players (FreeTubeApp#4036) * Sort list of external players * Condense sorting logic * Rework sorting in utils.js * Simplify sorting logic --- src/renderer/store/modules/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index acdf3096506dd..3d60cbf261311 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -501,7 +501,11 @@ const actions = { const externalPlayerMap = JSON.parse(fileData).map((entry) => { return { name: entry.name, nameTranslationKey: entry.nameTranslationKey, value: entry.value, cmdArguments: entry.cmdArguments } }) - + // Sort external players alphabetically & case-insensitive, keep default entry at the top + const playerNone = externalPlayerMap.shift() + externalPlayerMap.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })) + externalPlayerMap.unshift(playerNone) + const externalPlayerNames = externalPlayerMap.map((entry) => { return entry.name }) const externalPlayerNameTranslationKeys = externalPlayerMap.map((entry) => { return entry.nameTranslationKey }) const externalPlayerValues = externalPlayerMap.map((entry) => { return entry.value })