Sort bulk migration search entries
This commit is contained in:
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
- (**Migration**) Allow only 2 tracker requests per second
|
- (**Migration**) Allow only 2 tracker requests per second
|
||||||
- (**Migration**) Sort manga to migrate selection by title and by recently added to the library
|
- (**Migration**) Sort manga to migrate selection by title and by recently added to the library
|
||||||
- (**Migration**) Sort destination source selection by same order as browse source page
|
- (**Migration**) Sort destination source selection by same order as browse source page
|
||||||
|
- (**Migration**) Sort entries in search page by title
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,14 @@ import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'
|
|||||||
import { DEFAULT_FULL_FAB_HEIGHT } from '@/base/components/buttons/StyledFab.tsx';
|
import { DEFAULT_FULL_FAB_HEIGHT } from '@/base/components/buttons/StyledFab.tsx';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
|
import type { TMigrationEntry } from '@/features/migration/Migration.types.ts';
|
||||||
import { MigrationEntryStatus } from '@/features/migration/Migration.types.ts';
|
import { MigrationEntryStatus } from '@/features/migration/Migration.types.ts';
|
||||||
import { MigrationEntryGroup } from '@/features/migration/components/MIgrationEntryGroup.tsx';
|
import { MigrationEntryGroup } from '@/features/migration/components/MIgrationEntryGroup.tsx';
|
||||||
import { plural } from '@lingui/core/macro';
|
import { plural } from '@lingui/core/macro';
|
||||||
|
|
||||||
|
const getEntries = (status: MigrationEntryStatus, entries: TMigrationEntry[]): TMigrationEntry[] =>
|
||||||
|
entries.filter((entry) => entry.status === status).toSorted((a, b) => a.mangaTitle.localeCompare(b.mangaTitle));
|
||||||
|
|
||||||
export const MigrationSearch = () => {
|
export const MigrationSearch = () => {
|
||||||
const { t } = useLingui();
|
const { t } = useLingui();
|
||||||
const entries = MigrationManager.useEntries();
|
const entries = MigrationManager.useEntries();
|
||||||
@@ -46,26 +50,14 @@ export const MigrationSearch = () => {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return entryList.indexOf(a) - entryList.indexOf(b);
|
return a.mangaTitle.localeCompare(b.mangaTitle);
|
||||||
}),
|
}),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const failedEntries = useMemo(
|
const failedEntries = useMemo(() => getEntries(MigrationEntryStatus.SEARCH_FAILED, entryList), [entryList]);
|
||||||
() => entryList.filter((entry) => entry.status === MigrationEntryStatus.SEARCH_FAILED),
|
const noMatchEntries = useMemo(() => getEntries(MigrationEntryStatus.NO_MATCH, entryList), [entryList]);
|
||||||
[entryList],
|
const outdatedEntries = useMemo(() => getEntries(MigrationEntryStatus.OUTDATED, entryList), [entryList]);
|
||||||
);
|
const matchedEntries = useMemo(() => getEntries(MigrationEntryStatus.SEARCH_COMPLETE, entryList), [entryList]);
|
||||||
const noMatchEntries = useMemo(
|
|
||||||
() => entryList.filter((entry) => entry.status === MigrationEntryStatus.NO_MATCH),
|
|
||||||
[entryList],
|
|
||||||
);
|
|
||||||
const outdatedEntries = useMemo(
|
|
||||||
() => entryList.filter((entry) => entry.status === MigrationEntryStatus.OUTDATED),
|
|
||||||
[entryList],
|
|
||||||
);
|
|
||||||
const matchedEntries = useMemo(
|
|
||||||
() => entryList.filter((entry) => entry.status === MigrationEntryStatus.SEARCH_COMPLETE),
|
|
||||||
[entryList],
|
|
||||||
);
|
|
||||||
|
|
||||||
const hasMigratableEntries = useMemo(() => !!MigrationManager.getMigratableEntries().length, [entryList]);
|
const hasMigratableEntries = useMemo(() => !!MigrationManager.getMigratableEntries().length, [entryList]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user