Exclude "local source" for language detection for sources language filter
The local source is always shown, and therefore its language ("other") should only be shown in the language filter in case an actual source is installed that supports is of "other" language.
This commit is contained in:
@@ -56,6 +56,14 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
|
||||
}),
|
||||
[sources, shownLangs],
|
||||
);
|
||||
const sourcesForLanguageFilter = useMemo(
|
||||
() =>
|
||||
SourceService.filter(sources ?? [], {
|
||||
showNsfw,
|
||||
keepLocalSource: false,
|
||||
}),
|
||||
[sources],
|
||||
);
|
||||
const sourcesByLanguage = useMemo(() => {
|
||||
const lastUsedSource = SourceService.getLastUsedSource(lastUsedSourceId, filteredSources);
|
||||
const groupedByLanguageTuple = Object.entries(
|
||||
@@ -72,7 +80,10 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
|
||||
return groupedByLanguageTuple;
|
||||
}, [filteredSources]);
|
||||
|
||||
const sourceLanguages = useMemo(() => SourceService.getLanguages(sources ?? []), [sources]);
|
||||
const sourceLanguages = useMemo(
|
||||
() => SourceService.getLanguages(sourcesForLanguageFilter, { excludeLocalSource: true }),
|
||||
[sources],
|
||||
);
|
||||
const areSourcesFromDifferentRepos = useMemo(
|
||||
() => SourceService.areFromMultipleRepos(filteredSources),
|
||||
[filteredSources],
|
||||
@@ -108,10 +119,10 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
|
||||
selectedLanguages={shownLangs}
|
||||
setSelectedLanguages={setShownLangs}
|
||||
languages={sourceLanguages}
|
||||
sources={sources ?? []}
|
||||
sources={sourcesForLanguageFilter}
|
||||
/>
|
||||
</>,
|
||||
[t, shownLangs, sourceLanguages, sources],
|
||||
[t, shownLangs, sourceLanguages, sourcesForLanguageFilter],
|
||||
);
|
||||
|
||||
if (isLoading) return <LoadingPlaceholder />;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { GroupedVirtuoso } from 'react-virtuoso';
|
||||
import ListItemAvatar from '@mui/material/ListItemAvatar';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import Checkbox from '@mui/material/Checkbox';
|
||||
import Box from '@mui/material/Box';
|
||||
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
||||
import { translateExtensionLanguage } from '@/features/extension/Extensions.utils.ts';
|
||||
import { languageSortComparator, toUniqueLanguageCodes } from '@/base/utils/Languages.ts';
|
||||
@@ -139,6 +140,7 @@ export const SourceLanguageSelect = ({
|
||||
<Dialog fullWidth maxWidth="xs" open={open} onClose={handleCancel}>
|
||||
<DialogTitle>{t`Allowed Languages`}</DialogTitle>
|
||||
<DialogContent dividers sx={{ padding: 0 }}>
|
||||
{!languages.length && <Box sx={{ p: 1 }}>{t`No sources installed`}</Box>}
|
||||
<GroupedVirtuoso
|
||||
style={{
|
||||
height: languagesSortedBySelectState.length * 54,
|
||||
|
||||
@@ -46,8 +46,15 @@ export class Sources {
|
||||
return source.lang;
|
||||
}
|
||||
|
||||
static getLanguages(sources: (SourceIdInfo & SourceLanguageInfo)[]): string[] {
|
||||
return [...new Set(sources.map(Sources.getLanguage))];
|
||||
static getLanguages(
|
||||
sources: (SourceIdInfo & SourceLanguageInfo)[],
|
||||
{ excludeLocalSource = false }: { excludeLocalSource?: boolean } = {},
|
||||
): string[] {
|
||||
const filteredSources = excludeLocalSource
|
||||
? sources.filter((source) => !Sources.isLocalSource(source))
|
||||
: sources;
|
||||
|
||||
return [...new Set(filteredSources.map(Sources.getLanguage))];
|
||||
}
|
||||
|
||||
static groupByLanguage<Source extends SourceIdInfo & SourceLanguageInfo & SourceDisplayNameInfo & SourceMetaInfo>(
|
||||
|
||||
@@ -2300,6 +2300,10 @@ msgstr "No pages found"
|
||||
msgid "No sources found. Install Some extensions first."
|
||||
msgstr "No sources found. Install Some extensions first."
|
||||
|
||||
#: src/features/source/components/SourceLanguageSelect.tsx
|
||||
msgid "No sources installed"
|
||||
msgstr "No sources installed"
|
||||
|
||||
#: src/features/backup/Backup.utils.ts
|
||||
#: src/features/category/components/CategoriesInclusionSetting.tsx
|
||||
#: src/features/downloads/screens/DownloadSettings.tsx
|
||||
|
||||
Reference in New Issue
Block a user