mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
Merge pull request #950 from Stremio/feat/langs-alphabetic-ordering
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
This commit is contained in:
commit
ee5269e1c8
2 changed files with 8 additions and 7 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue