mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01: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'}
|
disabled={uiState === 'loading'}
|
||||||
>
|
>
|
||||||
{supportedLanguages
|
{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);
|
return commonA.localeCompare(commonB);
|
||||||
})
|
})
|
||||||
.map(([code, common, native]) => (
|
.map(([code, common, native]) => (
|
||||||
|
|
Loading…
Reference in a new issue