mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-20 00:33:10 +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));
|
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 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];
|
return [matchingOption, ...otherOptions];
|
||||||
}, [options, userLangCode, isLanguageDropdown]);
|
}, [options, userLangCode, isLanguageDropdown]);
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,10 @@ const usePlayerOptions = (profile: Profile) => {
|
||||||
const { core } = useServices();
|
const { core } = useServices();
|
||||||
const platform = usePlatform();
|
const platform = usePlatform();
|
||||||
|
|
||||||
const languageOptions = useMemo(() =>
|
const languageOptions = useMemo(() => Object.keys(LANGUAGES_NAMES).map((code) => ({
|
||||||
Object.keys(LANGUAGES_NAMES).map((code) => ({
|
value: code,
|
||||||
value: code,
|
label: LANGUAGES_NAMES[code]
|
||||||
label: LANGUAGES_NAMES[code]
|
})), []);
|
||||||
})), []);
|
|
||||||
|
|
||||||
const { sortedOptions: sortedLanguageOptions } = useLanguageSorting(languageOptions);
|
const { sortedOptions: sortedLanguageOptions } = useLanguageSorting(languageOptions);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue