Remove abbreviation of “language” in function names

This commit is contained in:
schroda
2025-05-09 00:42:56 +02:00
parent d27c5c445f
commit dcd57aea8f
8 changed files with 28 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
import { sourceDefualtLangs } from '@/modules/core/utils/Languages.ts';
import { sourceDefaultLanguages } from '@/modules/core/utils/Languages.ts';
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
import { SourceCard } from '@/modules/source/components/SourceCard.tsx';
import { LanguageSelect } from '@/modules/core/components/inputs/LanguageSelect.tsx';
@@ -31,7 +31,7 @@ import { useAppAction } from '@/modules/navigation-bar/hooks/useAppAction.ts';
export function Sources() {
const { t } = useTranslation();
const [shownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', sourceDefualtLangs());
const [shownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', sourceDefaultLanguages());
const {
settings: { showNsfw },
} = useMetadataServerSettings();

View File

@@ -15,7 +15,7 @@ import {
} from '@/modules/source/Source.types.ts';
import {
DefaultLanguage,
langSortCmp,
languageSortComparator,
toComparableLanguage,
toComparableLanguages,
toUniqueLanguageCodes,
@@ -37,14 +37,16 @@ export class Sources {
}
static getLanguages(sources: (SourceIdInfo & SourceLanguageInfo)[]): string[] {
return [...new Set(sources.map((source) => Sources.getLanguage(source)))].toSorted(langSortCmp);
return [...new Set(sources.map((source) => Sources.getLanguage(source)))].toSorted(languageSortComparator);
}
static groupByLanguage<Source extends SourceIdInfo & SourceLanguageInfo & SourceDisplayNameInfo>(
sources: Source[],
): Record<string, Source[]> {
const sourcesByLanguage = Object.groupBy(sources, (source) => Sources.getLanguage(source));
const sourcesBySortedLanguage = Object.entries(sourcesByLanguage).toSorted(([a], [b]) => langSortCmp(a, b));
const sourcesBySortedLanguage = Object.entries(sourcesByLanguage).toSorted(([a], [b]) =>
languageSortComparator(a, b),
);
const sortedSourcesBySortedLanguage = sourcesBySortedLanguage.map(([language, sourcesOfLanguage]) => [
language,
(sourcesOfLanguage ?? []).toSorted((a, b) => a.displayName.localeCompare(b.displayName)),