Cleanup Random library filter

This commit is contained in:
schroda
2026-07-21 01:04:10 +02:00
parent 9ed178342f
commit 12fe47768e
2 changed files with 16 additions and 33 deletions

View File

@@ -8,7 +8,6 @@
import ArrowDownward from '@mui/icons-material/ArrowDownward'; import ArrowDownward from '@mui/icons-material/ArrowDownward';
import ArrowUpward from '@mui/icons-material/ArrowUpward'; import ArrowUpward from '@mui/icons-material/ArrowUpward';
import Replay from '@mui/icons-material/Replay';
import { memo } from 'react'; import { memo } from 'react';
import type { RadioInputProps } from '@/base/components/inputs/RadioInput.tsx'; import type { RadioInputProps } from '@/base/components/inputs/RadioInput.tsx';
import { RadioInput } from '@/base/components/inputs/RadioInput.tsx'; import { RadioInput } from '@/base/components/inputs/RadioInput.tsx';
@@ -23,7 +22,3 @@ export const SortRadioInput = memo(({ sortDescending, ...rest }: IProps) => (
{...rest} {...rest}
/> />
)); ));
export const SortRadioInputRandom = memo(({ sortDescending, ...rest }: IProps) => (
<RadioInput checkedIcon={<Replay color="primary" />} {...rest} />
));

View File

@@ -16,7 +16,7 @@ import { useMemo } from 'react';
import uniqBy from 'lodash/fp/uniqBy'; import uniqBy from 'lodash/fp/uniqBy';
import { CheckboxInput } from '@/base/components/inputs/CheckboxInput.tsx'; import { CheckboxInput } from '@/base/components/inputs/CheckboxInput.tsx';
import { RadioInput } from '@/base/components/inputs/RadioInput.tsx'; import { RadioInput } from '@/base/components/inputs/RadioInput.tsx';
import { SortRadioInput, SortRadioInputRandom } from '@/base/components/inputs/SortRadioInput.tsx'; import { SortRadioInput } from '@/base/components/inputs/SortRadioInput.tsx';
import { ThreeStateCheckboxInput } from '@/base/components/inputs/ThreeStateCheckboxInput.tsx'; import { ThreeStateCheckboxInput } from '@/base/components/inputs/ThreeStateCheckboxInput.tsx';
import { OptionsTabs } from '@/base/components/modals/OptionsTabs.tsx'; import { OptionsTabs } from '@/base/components/modals/OptionsTabs.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts'; import { requestManager } from '@/lib/requests/RequestManager.ts';
@@ -38,6 +38,7 @@ import { MANGA_STATUS_TO_TRANSLATION } from '@/features/manga/Manga.constants.ts
import { GridLayout } from '@/base/Base.types'; import { GridLayout } from '@/base/Base.types';
import { getErrorMessage } from '@/lib/HelperFunctions.ts'; import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { Collapsable } from '@/base/components/Collapsable.tsx'; import { Collapsable } from '@/base/components/Collapsable.tsx';
import Replay from '@mui/icons-material/Replay';
const TITLES: { [key in 'filter' | 'sort' | 'display']: MessageDescriptor } = { const TITLES: { [key in 'filter' | 'sort' | 'display']: MessageDescriptor } = {
filter: msg`Filter`, filter: msg`Filter`,
@@ -211,24 +212,12 @@ export const LibraryOptionsPanel = ({
); );
} }
if (key === 'sort') { if (key === 'sort') {
return SORT_OPTIONS.map(([mode, label]) => return SORT_OPTIONS.map(([mode, label]) => (
mode === 'random' ? (
<SortRadioInputRandom
key={mode}
label={t(label)}
checked={categoryLibraryOptions.sortBy === mode}
sortDescending={categoryLibraryOptions.sortDesc}
onClick={() =>
mode !== categoryLibraryOptions.sortBy
? updateCategoryLibraryOptions('sortBy', mode)
: updateCategoryLibraryOptions('sortDesc', !categoryLibraryOptions.sortDesc)
}
/>
) : (
<SortRadioInput <SortRadioInput
key={mode} key={mode}
label={t(label)} label={t(label)}
checked={categoryLibraryOptions.sortBy === mode} checked={categoryLibraryOptions.sortBy === mode}
checkedIcon={mode === 'random' ? <Replay /> : undefined}
sortDescending={categoryLibraryOptions.sortDesc} sortDescending={categoryLibraryOptions.sortDesc}
onClick={() => onClick={() =>
mode !== categoryLibraryOptions.sortBy mode !== categoryLibraryOptions.sortBy
@@ -236,8 +225,7 @@ export const LibraryOptionsPanel = ({
: updateCategoryLibraryOptions('sortDesc', !categoryLibraryOptions.sortDesc) : updateCategoryLibraryOptions('sortDesc', !categoryLibraryOptions.sortDesc)
} }
/> />
), ));
);
} }
if (key === 'display') { if (key === 'display') {
return ( return (