mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 01:05:34 +03:00
Very very very lazy way to sort used languages to the top
This commit is contained in:
parent
5f5b1e5132
commit
8565bb930b
1 changed files with 18 additions and 1 deletions
|
@ -1084,7 +1084,24 @@ function Compose({
|
|||
disabled={uiState === 'loading'}
|
||||
>
|
||||
{supportedLanguages
|
||||
.sort(([, commonA], [, commonB]) => {
|
||||
.sort(([codeA, commonA], [codeB, commonB]) => {
|
||||
const { contentTranslationHideLanguages = [] } =
|
||||
states.settings;
|
||||
// Sort codes that same as language, prevLanguage, DEFAULT_LANGUAGE and all the ones in states.settings.contentTranslationHideLanguages, to the top
|
||||
if (
|
||||
codeA === language ||
|
||||
codeA === prevLanguage ||
|
||||
codeA === DEFAULT_LANG ||
|
||||
contentTranslationHideLanguages?.includes(codeA)
|
||||
)
|
||||
return -1;
|
||||
if (
|
||||
codeB === language ||
|
||||
codeB === prevLanguage ||
|
||||
codeB === DEFAULT_LANG ||
|
||||
contentTranslationHideLanguages?.includes(codeB)
|
||||
)
|
||||
return 1;
|
||||
return commonA.localeCompare(commonB);
|
||||
})
|
||||
.map(([code, common, native]) => (
|
||||
|
|
Loading…
Reference in a new issue