From f7f97b551ccec13c09b5e626f19d7babca871e2e Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 25 Jun 2025 16:54:21 +0300 Subject: [PATCH 1/2] feat(Settings): langs alphabetic ordering --- src/routes/Settings/Player/usePlayerOptions.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/routes/Settings/Player/usePlayerOptions.ts b/src/routes/Settings/Player/usePlayerOptions.ts index 982c5138e..383709604 100644 --- a/src/routes/Settings/Player/usePlayerOptions.ts +++ b/src/routes/Settings/Player/usePlayerOptions.ts @@ -10,18 +10,17 @@ const usePlayerOptions = (profile: Profile) => { const { core } = useServices(); const platform = usePlatform(); - const languageOptions = useMemo(() => - Object.keys(LANGUAGES_NAMES).map((code) => ({ - value: code, - label: LANGUAGES_NAMES[code] - })), []); + const languageOptions = useMemo(() => Object.keys(LANGUAGES_NAMES).map((code) => ({ + value: code, + label: LANGUAGES_NAMES[code] + })), []); const { sortedOptions: sortedLanguageOptions } = useLanguageSorting(languageOptions); const subtitlesLanguageSelect = useMemo(() => ({ options: [ { value: null, label: t('NONE') }, - ...sortedLanguageOptions + ...sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)) ], value: profile.settings.subtitlesLanguage, onSelect: (value: string) => { @@ -110,7 +109,7 @@ const usePlayerOptions = (profile: Profile) => { }), [profile.settings]); const audioLanguageSelect = useMemo(() => ({ - options: sortedLanguageOptions, + options: sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)), value: profile.settings.audioLanguage, onSelect: (value: string) => { core.transport.dispatch({ From 652a042a557974b9b5bcfa4a24b4994c46bb52a6 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Wed, 25 Jun 2025 16:59:16 +0300 Subject: [PATCH 2/2] fix(Settings): correctly sort without matchingidx --- src/common/useLanguageSorting.ts | 6 ++++-- src/routes/Settings/Player/usePlayerOptions.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/useLanguageSorting.ts b/src/common/useLanguageSorting.ts index 44c8927bd..d5969cf76 100644 --- a/src/common/useLanguageSorting.ts +++ b/src/common/useLanguageSorting.ts @@ -22,10 +22,12 @@ const useLanguageSorting = (options: MultiselectMenuOption[]) => { return userLangCode.some((code) => lang?.codes.includes(code)); }); - if (matchingIndex === -1) return options; + if (matchingIndex === -1) { + return [...options].sort((a, b) => a.label.localeCompare(b.label)); + } const matchingOption = options[matchingIndex]; - const otherOptions = options.filter((_, index) => index !== matchingIndex); + const otherOptions = options.filter((_, idx) => idx !== matchingIndex).sort((a, b) => a.label.localeCompare(b.label)); return [matchingOption, ...otherOptions]; }, [options, userLangCode, isLanguageDropdown]); diff --git a/src/routes/Settings/Player/usePlayerOptions.ts b/src/routes/Settings/Player/usePlayerOptions.ts index 383709604..edbce3d24 100644 --- a/src/routes/Settings/Player/usePlayerOptions.ts +++ b/src/routes/Settings/Player/usePlayerOptions.ts @@ -20,7 +20,7 @@ const usePlayerOptions = (profile: Profile) => { const subtitlesLanguageSelect = useMemo(() => ({ options: [ { value: null, label: t('NONE') }, - ...sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)) + ...sortedLanguageOptions ], value: profile.settings.subtitlesLanguage, onSelect: (value: string) => { @@ -109,7 +109,7 @@ const usePlayerOptions = (profile: Profile) => { }), [profile.settings]); const audioLanguageSelect = useMemo(() => ({ - options: sortedLanguageOptions.sort((a, b) => a.label.localeCompare(b.label)), + options: sortedLanguageOptions, value: profile.settings.audioLanguage, onSelect: (value: string) => { core.transport.dispatch({