Remove "sourceForcedDefaultLangs"
This commit is contained in:
@@ -59,11 +59,7 @@ export function extensionDefaultLangs(): string[] {
|
||||
}
|
||||
|
||||
export function sourceDefualtLangs(): string[] {
|
||||
return [...defaultNativeLang(), DefaultLanguage.LOCAL_SOURCE];
|
||||
}
|
||||
|
||||
export function sourceForcedDefaultLangs(): string[] {
|
||||
return [DefaultLanguage.LOCAL_SOURCE];
|
||||
return [...defaultNativeLang()];
|
||||
}
|
||||
|
||||
export const langSortCmp = (a: string, b: string) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import Box from '@mui/material/Box';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
|
||||
import { langSortCmp, sourceDefualtLangs, sourceForcedDefaultLangs } from '@/modules/core/utils/Languages.ts';
|
||||
import { langSortCmp, sourceDefualtLangs } from '@/modules/core/utils/Languages.ts';
|
||||
import { AppbarSearch } from '@/modules/core/components/AppbarSearch.tsx';
|
||||
import { LangSelect } from '@/modules/core/components/inputs/LangSelect.tsx';
|
||||
import { useDebounce } from '@/modules/core/hooks/useDebounce.ts';
|
||||
@@ -217,7 +217,7 @@ export const SearchAll: React.FC = () => {
|
||||
|
||||
const sourcesSortedByName = useMemo(() => [...sources].sort(compareSourceByName), [sources]);
|
||||
const sourcesFilteredByLang = useMemo(
|
||||
() => sourcesSortedByName.filter((source) => shownLangs.includes(source.lang)),
|
||||
() => sourcesSortedByName.filter((source) => shownLangs.includes(source.lang) || Number(source.id) === 0),
|
||||
[sourcesSortedByName, shownLangs],
|
||||
);
|
||||
const sourcesFilteredByNsfw = useMemo(
|
||||
@@ -262,14 +262,6 @@ export const SearchAll: React.FC = () => {
|
||||
};
|
||||
}, [t, shownLangs, setShownLangs, sources]);
|
||||
|
||||
useEffect(() => {
|
||||
// make sure all of forcedDefaultLangs() exists in shownLangs
|
||||
const missingDefaultLangs = sourceForcedDefaultLangs().filter(
|
||||
(defaultLang) => !shownLangs.includes(defaultLang),
|
||||
);
|
||||
setShownLangs([...shownLangs, ...missingDefaultLangs]);
|
||||
}, []);
|
||||
|
||||
if (loading) {
|
||||
return <LoadingPlaceholder />;
|
||||
}
|
||||
|
||||
@@ -15,12 +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,
|
||||
sourceForcedDefaultLangs,
|
||||
langSortCmp,
|
||||
DefaultLanguage,
|
||||
} from '@/modules/core/utils/Languages.ts';
|
||||
import { sourceDefualtLangs, langSortCmp, DefaultLanguage } from '@/modules/core/utils/Languages.ts';
|
||||
import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx';
|
||||
import { SourceCard } from '@/modules/source/components/SourceCard.tsx';
|
||||
import { LangSelect } from '@/modules/core/components/inputs/LangSelect.tsx';
|
||||
@@ -67,11 +62,7 @@ export function Sources() {
|
||||
const { t } = useTranslation();
|
||||
const { setAction } = useNavBarContext();
|
||||
|
||||
const [savedShownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', sourceDefualtLangs());
|
||||
const shownLangs = useMemo(
|
||||
() => [...new Set([...savedShownLangs, ...sourceDefualtLangs(), ...sourceForcedDefaultLangs()])],
|
||||
[savedShownLangs],
|
||||
);
|
||||
const [shownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', sourceDefualtLangs());
|
||||
const [showNsfw] = useLocalStorage<boolean>('showNsfw', true);
|
||||
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user