mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
fix(Settings): correctly sort without matchingidx
This commit is contained in:
parent
f7f97b551c
commit
652a042a55
2 changed files with 6 additions and 4 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]);
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue