Show source "language subtitle" only for "last used" and "pinned" sources
The others are already grouped by language, which makes this information redundant
This commit is contained in:
@@ -53,15 +53,15 @@ export const isExtensionState = (value: string): boolean =>
|
|||||||
value as ExtensionGroupState,
|
value as ExtensionGroupState,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const isPinnedOrLastUsedSource = (languageCode: string): boolean =>
|
||||||
|
[DefaultLanguage.PINNED, DefaultLanguage.LAST_USED_SOURCE].includes(languageCode as DefaultLanguage);
|
||||||
|
|
||||||
export const isExtensionStateOrLanguage = (languageCode: string): boolean =>
|
export const isExtensionStateOrLanguage = (languageCode: string): boolean =>
|
||||||
isExtensionState(languageCode) ||
|
isExtensionState(languageCode) ||
|
||||||
[
|
isPinnedOrLastUsedSource(languageCode) ||
|
||||||
DefaultLanguage.ALL,
|
[DefaultLanguage.ALL, DefaultLanguage.OTHER, DefaultLanguage.LOCAL_SOURCE].includes(
|
||||||
DefaultLanguage.OTHER,
|
languageCode as DefaultLanguage,
|
||||||
DefaultLanguage.LOCAL_SOURCE,
|
);
|
||||||
DefaultLanguage.PINNED,
|
|
||||||
DefaultLanguage.LAST_USED_SOURCE,
|
|
||||||
].includes(languageCode as DefaultLanguage);
|
|
||||||
|
|
||||||
export const translateExtensionLanguage = (languageCode: string): string =>
|
export const translateExtensionLanguage = (languageCode: string): string =>
|
||||||
isExtensionStateOrLanguage(languageCode)
|
isExtensionStateOrLanguage(languageCode)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import IconButton from '@mui/material/IconButton';
|
|||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { SourceContentType } from '@/modules/source/screens/SourceMangas.tsx';
|
import { SourceContentType } from '@/modules/source/screens/SourceMangas.tsx';
|
||||||
import { GetSourcesListQuery } from '@/lib/graphql/generated/graphql.ts';
|
import { GetSourcesListQuery } from '@/lib/graphql/generated/graphql.ts';
|
||||||
import { translateExtensionLanguage } from '@/modules/extension/Extensions.utils.ts';
|
|
||||||
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
||||||
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
||||||
import { Sources } from '@/modules/source/services/Sources.ts';
|
import { Sources } from '@/modules/source/services/Sources.ts';
|
||||||
@@ -30,16 +29,18 @@ import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
|||||||
import { createUpdateSourceMetadata, useGetSourceMetadata } from '@/modules/source/services/SourceMetadata.ts';
|
import { createUpdateSourceMetadata, useGetSourceMetadata } from '@/modules/source/services/SourceMetadata.ts';
|
||||||
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
import { makeToast } from '@/modules/core/utils/Toast.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
|
import { languageCodeToName } from '@/modules/core/utils/Languages.ts';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
source: GetSourcesListQuery['sources']['nodes'][number];
|
source: GetSourcesListQuery['sources']['nodes'][number];
|
||||||
showSourceRepo: boolean;
|
showSourceRepo: boolean;
|
||||||
|
showLanguage: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { source, showSourceRepo } = props;
|
const { source, showSourceRepo, showLanguage } = props;
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
@@ -79,7 +80,7 @@ export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
|||||||
{sourceName}
|
{sourceName}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="caption">
|
<Typography variant="caption">
|
||||||
{translateExtensionLanguage(lang)}
|
{showLanguage && languageCodeToName(lang)}
|
||||||
{isNsfw && (
|
{isNsfw && (
|
||||||
<Typography variant="caption" color="error">
|
<Typography variant="caption" color="error">
|
||||||
{' 18+'}
|
{' 18+'}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { SourceCard } from '@/modules/source/components/SourceCard.tsx';
|
|||||||
import { LanguageSelect } from '@/modules/core/components/inputs/LanguageSelect.tsx';
|
import { LanguageSelect } from '@/modules/core/components/inputs/LanguageSelect.tsx';
|
||||||
import { EmptyViewAbsoluteCentered } from '@/modules/core/components/feedback/EmptyViewAbsoluteCentered.tsx';
|
import { EmptyViewAbsoluteCentered } from '@/modules/core/components/feedback/EmptyViewAbsoluteCentered.tsx';
|
||||||
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
||||||
import { translateExtensionLanguage } from '@/modules/extension/Extensions.utils.ts';
|
import { isPinnedOrLastUsedSource, translateExtensionLanguage } from '@/modules/extension/Extensions.utils.ts';
|
||||||
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
import { Sources as SourceService } from '@/modules/source/services/Sources.ts';
|
import { Sources as SourceService } from '@/modules/source/services/Sources.ts';
|
||||||
@@ -140,12 +140,17 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
|
|||||||
</StyledGroupHeader>
|
</StyledGroupHeader>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
itemContent={(index) => {
|
itemContent={(index, groupIndex) => {
|
||||||
|
const language = sourcesByLanguage[groupIndex][0];
|
||||||
const source = visibleSources[index];
|
const source = visibleSources[index];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledGroupItemWrapper>
|
<StyledGroupItemWrapper>
|
||||||
<SourceCard source={source} showSourceRepo={areSourcesFromDifferentRepos} />
|
<SourceCard
|
||||||
|
source={source}
|
||||||
|
showSourceRepo={areSourcesFromDifferentRepos}
|
||||||
|
showLanguage={isPinnedOrLastUsedSource(language)}
|
||||||
|
/>
|
||||||
</StyledGroupItemWrapper>
|
</StyledGroupItemWrapper>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user