Skip to content

Commit

Permalink
Sort list of external players (FreeTubeApp#4036)
Browse files Browse the repository at this point in the history
Sort list of external players (FreeTubeApp#4036)
* Sort list of external players
* Condense sorting logic
* Rework sorting in utils.js
* Simplify sorting logic
  • Loading branch information
vdbhb59 authored Oct 8, 2023
1 parent c4fb2a3 commit 7b2d3bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/renderer/store/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 7b2d3bf

Please sign in to comment.