Support library batch selection migration

Closes #1089
This commit is contained in:
schroda
2026-04-23 15:18:35 +02:00
parent 172c522d01
commit 527769ec5e
17 changed files with 172 additions and 144 deletions

View File

@@ -68,7 +68,7 @@ export const MigrationExecute = () => {
})}
entries={migratingEntries}
isMigrating
color="error"
color="info"
/>
<MigrationEntryGroup
status={MigrationEntryStatus.MIGRATION_FAILED}

View File

@@ -71,7 +71,7 @@ export const MigrationSearch = () => {
other: '# searching',
})}
entries={searchingEntries}
color="error"
color="info"
/>
<MigrationEntryGroup
status={MigrationEntryStatus.SEARCH_FAILED}

View File

@@ -31,7 +31,7 @@ import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
export const MigrationSelectDestinationSources = () => {
const { t } = useLingui();
const currentSourceId = MigrationManager.useSourceId();
const currentSourceIds = MigrationManager.useSourceIds();
const {
settings: { browseLanguages, showNsfw },
@@ -156,7 +156,7 @@ export const MigrationSelectDestinationSources = () => {
selectedSourceIds={selectedItemIds}
handleSelection={handleSelection}
handlePriorityChange={handlePriorityChange}
currentSourceId={currentSourceId}
currentSourceIds={currentSourceIds}
/>
<Fab
variant="extended"

View File

@@ -26,8 +26,6 @@ import { SelectableCollectionSelectMode } from '@/base/collection/components/Sel
import { Mangas } from '@/features/manga/services/Mangas.ts';
import { STABLE_EMPTY_ARRAY } from '@/base/Base.constants.ts';
import { MigrationContinueButton } from '@/features/migration/components/MigrationContinueButton.tsx';
import { AppRoutes } from '@/base/AppRoute.constants.ts';
import { ReactRouter } from '@/lib/react-router/ReactRouter.ts';
const getSourceError = (error: unknown): unknown => {
const message = getErrorMessage(error);
@@ -45,9 +43,11 @@ const getSourceError = (error: unknown): unknown => {
export const MigrationSelectMangas = () => {
const { t } = useLingui();
const sourceId = MigrationManager.useSourceId();
const sourceIds = MigrationManager.useSourceIds();
const selectedMangas = MigrationManager.useEntries();
const sourceId = sourceIds?.[0];
const [gridLayout, setGridLayout] = useLocalStorage('migrateGridLayout', GridLayout.List);
const {
@@ -58,7 +58,7 @@ export const MigrationSelectMangas = () => {
} = requestManager.useGetSource<GetSourceMigratableQuery, GetSourceMigratableQueryVariables>(
GET_SOURCE_MIGRATABLE,
sourceId ?? '',
{ skip: !sourceId, notifyOnNetworkStatusChange: true },
{ skip: !sourceIds, notifyOnNetworkStatusChange: true },
);
const {
@@ -67,7 +67,7 @@ export const MigrationSelectMangas = () => {
error: mangasError,
refetch: refetchMangas,
} = requestManager.useGetMigratableSourceMangas(sourceId!, {
skip: !sourceId,
skip: !sourceIds,
notifyOnNetworkStatusChange: true,
});
@@ -86,7 +86,7 @@ export const MigrationSelectMangas = () => {
),
});
const sourceName = migratableSourceData?.source?.displayName ?? sourceId ?? t`Migrate`;
const sourceName = migratableSourceData?.source?.displayName ?? sourceIds ?? t`Migrate`;
useAppTitleAndAction(
sourceName,
<>
@@ -108,22 +108,6 @@ export const MigrationSelectMangas = () => {
const handleContinue = () => {
const selected = mangas.filter((manga) => selectedItemIds.includes(manga.id));
const [entry] = selected;
const isSingleManga = selected.length === 1;
if (isSingleManga && entry) {
ReactRouter.navigate(
AppRoutes.migrate.childRoutes.singleMangaSearch.path(entry.sourceId, entry.id, entry.title),
{
state: { mangaTitle: entry.title },
},
);
MigrationManager.reset();
return;
}
MigrationManager.selectMangas(selected);
};

View File

@@ -19,11 +19,14 @@ import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { LoadingPlaceholder } from '@/base/components/feedback/LoadingPlaceholder.tsx';
import { EmptyViewAbsoluteCentered } from '@/base/components/feedback/EmptyViewAbsoluteCentered.tsx';
import type { TMigratableSource } from '@/features/migration/components/MigrationCard.tsx';
import { MigrationCard } from '@/features/migration/components/MigrationCard.tsx';
import { StyledGroupItemWrapper } from '@/base/components/virtuoso/StyledGroupItemWrapper.tsx';
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import type { SortSettings, TMigratableSourcesResult } from '@/features/migration/Migration.types.ts';
import type {
SortSettings,
TMigratableSource,
TMigratableSourcesResult,
} from '@/features/migration/Migration.types.ts';
import { SortBy, SortOrder } from '@/features/migration/Migration.types.ts';
import { sortByToTranslation, sortOrderToTranslation } from '@/features/migration/Migration.constants.ts';
import {