Merge pull request #950 from Stremio/feat/langs-alphabetic-ordering
Some checks are pending
Build / build (push) Waiting to run

This commit is contained in:
Timothy Z. 2025-06-25 17:58:36 +03:00 committed by GitHub
commit ee5269e1c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -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]);

View file

@ -10,11 +10,10 @@ 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);