Remove manual migration progress tracking
This commit is contained in:
@@ -39,8 +39,6 @@ export const DEFAULT_MIGRATION_STATE: MigrationState = {
|
|||||||
destinationSourceIds: [],
|
destinationSourceIds: [],
|
||||||
searchOptions: null,
|
searchOptions: null,
|
||||||
migrateOptions: null,
|
migrateOptions: null,
|
||||||
searchProgress: { total: 0, completed: 0, success: 0, failed: 0 },
|
|
||||||
migrationProgress: { total: 0, completed: 0, success: 0, failed: 0 },
|
|
||||||
startedAt: null,
|
startedAt: null,
|
||||||
lastUpdatedAt: null,
|
lastUpdatedAt: null,
|
||||||
groupExpandState: {},
|
groupExpandState: {},
|
||||||
@@ -52,22 +50,23 @@ export const ENTRY_STATUS_TRANSLATION: Record<MigrationEntryStatus, MessageDescr
|
|||||||
[MigrationEntryStatus.SEARCHING]: msg`Searching…`,
|
[MigrationEntryStatus.SEARCHING]: msg`Searching…`,
|
||||||
[MigrationEntryStatus.SEARCH_COMPLETE]: msg`Match found`,
|
[MigrationEntryStatus.SEARCH_COMPLETE]: msg`Match found`,
|
||||||
[MigrationEntryStatus.SEARCH_FAILED]: msg`Search failed`,
|
[MigrationEntryStatus.SEARCH_FAILED]: msg`Search failed`,
|
||||||
[MigrationEntryStatus.NO_MATCH]: msg`No match found`,
|
[MigrationEntryStatus.SEARCH_NO_MATCH]: msg`No match found`,
|
||||||
[MigrationEntryStatus.OUTDATED]: msg`Only outdated matches found`,
|
[MigrationEntryStatus.SEARCH_OUTDATED]: msg`Only outdated matches found`,
|
||||||
|
[MigrationEntryStatus.SEARCH_ABORTED]: msg`Aborted`,
|
||||||
[MigrationEntryStatus.MIGRATION_PENDING]: msg`Pending…`,
|
[MigrationEntryStatus.MIGRATION_PENDING]: msg`Pending…`,
|
||||||
[MigrationEntryStatus.MIGRATING]: msg`Migrating…`,
|
[MigrationEntryStatus.MIGRATING]: msg`Migrating…`,
|
||||||
[MigrationEntryStatus.MIGRATION_COMPLETE]: msg`Successfully migrated`,
|
[MigrationEntryStatus.MIGRATION_COMPLETE]: msg`Successfully migrated`,
|
||||||
[MigrationEntryStatus.MIGRATION_FAILED]: msg`Migration failed`,
|
[MigrationEntryStatus.MIGRATION_FAILED]: msg`Migration failed`,
|
||||||
|
[MigrationEntryStatus.MIGRATION_ABORTED]: msg`Aborted`,
|
||||||
[MigrationEntryStatus.EXCLUDED]: msg`Excluded`,
|
[MigrationEntryStatus.EXCLUDED]: msg`Excluded`,
|
||||||
[MigrationEntryStatus.ABORTED]: msg`Aborted`,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MIGRATE_SEARCH_ENTRY_GROUPS = [
|
export const MIGRATE_SEARCH_ENTRY_GROUPS = [
|
||||||
MigrationEntryStatus.SEARCHING,
|
MigrationEntryStatus.SEARCHING,
|
||||||
MigrationEntryStatus.SEARCH_FAILED,
|
MigrationEntryStatus.SEARCH_FAILED,
|
||||||
MigrationEntryStatus.ABORTED,
|
MigrationEntryStatus.SEARCH_ABORTED,
|
||||||
MigrationEntryStatus.NO_MATCH,
|
MigrationEntryStatus.SEARCH_NO_MATCH,
|
||||||
MigrationEntryStatus.OUTDATED,
|
MigrationEntryStatus.SEARCH_OUTDATED,
|
||||||
MigrationEntryStatus.SEARCH_COMPLETE,
|
MigrationEntryStatus.SEARCH_COMPLETE,
|
||||||
] as const satisfies readonly MigrationEntryStatus[];
|
] as const satisfies readonly MigrationEntryStatus[];
|
||||||
|
|
||||||
@@ -77,18 +76,18 @@ export const MIGRATE_SEARCH_ENTRY_GROUP_EXPAND_DEFAULT_STATE: Record<
|
|||||||
> = {
|
> = {
|
||||||
[MigrationEntryStatus.SEARCHING]: true,
|
[MigrationEntryStatus.SEARCHING]: true,
|
||||||
[MigrationEntryStatus.SEARCH_FAILED]: false,
|
[MigrationEntryStatus.SEARCH_FAILED]: false,
|
||||||
[MigrationEntryStatus.ABORTED]: false,
|
[MigrationEntryStatus.SEARCH_ABORTED]: false,
|
||||||
[MigrationEntryStatus.NO_MATCH]: false,
|
[MigrationEntryStatus.SEARCH_NO_MATCH]: false,
|
||||||
[MigrationEntryStatus.OUTDATED]: false,
|
[MigrationEntryStatus.SEARCH_OUTDATED]: false,
|
||||||
[MigrationEntryStatus.SEARCH_COMPLETE]: false,
|
[MigrationEntryStatus.SEARCH_COMPLETE]: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MIGRATE_EXECUTE_ENTRY_GROUPS = [
|
export const MIGRATE_EXECUTE_ENTRY_GROUPS = [
|
||||||
MigrationEntryStatus.MIGRATING,
|
MigrationEntryStatus.MIGRATING,
|
||||||
MigrationEntryStatus.MIGRATION_FAILED,
|
MigrationEntryStatus.MIGRATION_FAILED,
|
||||||
MigrationEntryStatus.ABORTED,
|
MigrationEntryStatus.MIGRATION_ABORTED,
|
||||||
MigrationEntryStatus.NO_MATCH,
|
MigrationEntryStatus.SEARCH_NO_MATCH,
|
||||||
MigrationEntryStatus.OUTDATED,
|
MigrationEntryStatus.SEARCH_OUTDATED,
|
||||||
MigrationEntryStatus.EXCLUDED,
|
MigrationEntryStatus.EXCLUDED,
|
||||||
MigrationEntryStatus.MIGRATION_COMPLETE,
|
MigrationEntryStatus.MIGRATION_COMPLETE,
|
||||||
] as const satisfies readonly MigrationEntryStatus[];
|
] as const satisfies readonly MigrationEntryStatus[];
|
||||||
@@ -99,9 +98,9 @@ export const MIGRATE_EXECUTE_ENTRY_GROUP_EXPAND_DEFAULT_STATE: Record<
|
|||||||
> = {
|
> = {
|
||||||
[MigrationEntryStatus.MIGRATING]: true,
|
[MigrationEntryStatus.MIGRATING]: true,
|
||||||
[MigrationEntryStatus.MIGRATION_FAILED]: false,
|
[MigrationEntryStatus.MIGRATION_FAILED]: false,
|
||||||
[MigrationEntryStatus.ABORTED]: false,
|
[MigrationEntryStatus.MIGRATION_ABORTED]: false,
|
||||||
[MigrationEntryStatus.NO_MATCH]: false,
|
[MigrationEntryStatus.SEARCH_NO_MATCH]: false,
|
||||||
[MigrationEntryStatus.OUTDATED]: false,
|
[MigrationEntryStatus.SEARCH_OUTDATED]: false,
|
||||||
[MigrationEntryStatus.EXCLUDED]: false,
|
[MigrationEntryStatus.EXCLUDED]: false,
|
||||||
[MigrationEntryStatus.MIGRATION_COMPLETE]: false,
|
[MigrationEntryStatus.MIGRATION_COMPLETE]: false,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -92,14 +92,15 @@ export enum MigrationEntryStatus {
|
|||||||
SEARCHING = 'searching',
|
SEARCHING = 'searching',
|
||||||
SEARCH_COMPLETE = 'search_complete',
|
SEARCH_COMPLETE = 'search_complete',
|
||||||
SEARCH_FAILED = 'search_failed',
|
SEARCH_FAILED = 'search_failed',
|
||||||
OUTDATED = 'outdated',
|
SEARCH_ABORTED = 'search_aborted',
|
||||||
NO_MATCH = 'no_match',
|
SEARCH_OUTDATED = 'search_outdated',
|
||||||
|
SEARCH_NO_MATCH = 'search_no_match',
|
||||||
MIGRATION_PENDING = 'migration_pending',
|
MIGRATION_PENDING = 'migration_pending',
|
||||||
MIGRATING = 'migrating',
|
MIGRATING = 'migrating',
|
||||||
MIGRATION_COMPLETE = 'migration_complete',
|
MIGRATION_COMPLETE = 'migration_complete',
|
||||||
MIGRATION_FAILED = 'migration_failed',
|
MIGRATION_FAILED = 'migration_failed',
|
||||||
|
MIGRATION_ABORTED = 'migration_aborted',
|
||||||
EXCLUDED = 'excluded',
|
EXCLUDED = 'excluded',
|
||||||
ABORTED = 'aborted',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MigrationMatch
|
export interface MigrationMatch
|
||||||
@@ -149,8 +150,6 @@ export interface MigrationState {
|
|||||||
destinationSourceIds: SourceIdInfo['id'][];
|
destinationSourceIds: SourceIdInfo['id'][];
|
||||||
searchOptions: MigrationBulkSearchSettings | null;
|
searchOptions: MigrationBulkSearchSettings | null;
|
||||||
migrateOptions: Omit<MigrateOptions, 'mangaIdToMigrateTo'> | null;
|
migrateOptions: Omit<MigrateOptions, 'mangaIdToMigrateTo'> | null;
|
||||||
searchProgress: MigrationProgress;
|
|
||||||
migrationProgress: MigrationProgress;
|
|
||||||
startedAt: number | null;
|
startedAt: number | null;
|
||||||
lastUpdatedAt: number | null;
|
lastUpdatedAt: number | null;
|
||||||
groupExpandState: Partial<Record<MigrationEntryStatus, boolean>>;
|
groupExpandState: Partial<Record<MigrationEntryStatus, boolean>>;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
MigrationEntryStatus,
|
MigrationEntryStatus,
|
||||||
type MigrationMatch,
|
type MigrationMatch,
|
||||||
MigrationPhase,
|
MigrationPhase,
|
||||||
|
type MigrationProgress,
|
||||||
type MigrationState,
|
type MigrationState,
|
||||||
type TMigrationEntry,
|
type TMigrationEntry,
|
||||||
} from '@/features/migration/Migration.types.ts';
|
} from '@/features/migration/Migration.types.ts';
|
||||||
@@ -226,20 +227,15 @@ export class MigrationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static isPhaseComplete(): boolean {
|
static isPhaseComplete(): boolean {
|
||||||
const { phase } = MigrationManager.getState();
|
const { phase, isAborted } = MigrationManager.getState();
|
||||||
|
const searchProgress = MigrationManager.getSearchProgress();
|
||||||
|
const migrationProgress = MigrationManager.getMigrationProgress();
|
||||||
|
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case MigrationPhase.SEARCHING:
|
case MigrationPhase.SEARCHING:
|
||||||
return (
|
return searchProgress.completed === searchProgress.total;
|
||||||
MigrationManager.getState().searchProgress.completed ===
|
|
||||||
MigrationManager.getState().searchProgress.total
|
|
||||||
);
|
|
||||||
case MigrationPhase.MIGRATING:
|
case MigrationPhase.MIGRATING:
|
||||||
return (
|
return isAborted || migrationProgress.completed === migrationProgress.total;
|
||||||
MigrationManager.getState().isAborted ||
|
|
||||||
MigrationManager.getState().migrationProgress.completed ===
|
|
||||||
MigrationManager.getState().migrationProgress.total
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -401,13 +397,11 @@ export class MigrationManager {
|
|||||||
await MigrationManager.awaitUserConfirmation();
|
await MigrationManager.awaitUserConfirmation();
|
||||||
|
|
||||||
const state = MigrationManager.getState();
|
const state = MigrationManager.getState();
|
||||||
const entryIds = Object.keys(state.entries).map(Number);
|
|
||||||
|
|
||||||
MigrationManager.updateState((draft) => {
|
MigrationManager.updateState((draft) => {
|
||||||
draft.phase = MigrationPhase.SEARCHING;
|
draft.phase = MigrationPhase.SEARCHING;
|
||||||
draft.destinationSourceIds = destinationSourceIds;
|
draft.destinationSourceIds = destinationSourceIds;
|
||||||
draft.searchOptions = options;
|
draft.searchOptions = options;
|
||||||
draft.searchProgress = { total: entryIds.length, completed: 0, success: 0, failed: 0 };
|
|
||||||
draft.startedAt = Date.now();
|
draft.startedAt = Date.now();
|
||||||
draft.groupExpandState = MIGRATE_SEARCH_ENTRY_GROUP_EXPAND_DEFAULT_STATE;
|
draft.groupExpandState = MIGRATE_SEARCH_ENTRY_GROUP_EXPAND_DEFAULT_STATE;
|
||||||
});
|
});
|
||||||
@@ -437,7 +431,7 @@ export class MigrationManager {
|
|||||||
try {
|
try {
|
||||||
await Promise.allSettled(searchPromises);
|
await Promise.allSettled(searchPromises);
|
||||||
} finally {
|
} finally {
|
||||||
const { searchProgress } = MigrationManager.getState();
|
const searchProgress = MigrationManager.getSearchProgress();
|
||||||
|
|
||||||
if (searchProgress.completed === searchProgress.total) {
|
if (searchProgress.completed === searchProgress.total) {
|
||||||
const allSearchesFailed = searchProgress.failed === searchProgress.total;
|
const allSearchesFailed = searchProgress.failed === searchProgress.total;
|
||||||
@@ -446,8 +440,8 @@ export class MigrationManager {
|
|||||||
draft.groupExpandState = {
|
draft.groupExpandState = {
|
||||||
...MIGRATE_SEARCH_ENTRY_GROUP_EXPAND_DEFAULT_STATE,
|
...MIGRATE_SEARCH_ENTRY_GROUP_EXPAND_DEFAULT_STATE,
|
||||||
[MigrationEntryStatus.SEARCHING]: false,
|
[MigrationEntryStatus.SEARCHING]: false,
|
||||||
[MigrationEntryStatus.NO_MATCH]: !allSearchesFailed && !searchProgress.success,
|
[MigrationEntryStatus.SEARCH_NO_MATCH]: !allSearchesFailed && !searchProgress.success,
|
||||||
[MigrationEntryStatus.OUTDATED]: !allSearchesFailed && !searchProgress.success,
|
[MigrationEntryStatus.SEARCH_OUTDATED]: !allSearchesFailed && !searchProgress.success,
|
||||||
[MigrationEntryStatus.SEARCH_FAILED]: allSearchesFailed,
|
[MigrationEntryStatus.SEARCH_FAILED]: allSearchesFailed,
|
||||||
[MigrationEntryStatus.SEARCH_COMPLETE]: !!searchProgress.success,
|
[MigrationEntryStatus.SEARCH_COMPLETE]: !!searchProgress.success,
|
||||||
};
|
};
|
||||||
@@ -466,7 +460,6 @@ export class MigrationManager {
|
|||||||
MigrationManager.updateState((draft) => {
|
MigrationManager.updateState((draft) => {
|
||||||
draft.phase = MigrationPhase.MIGRATING;
|
draft.phase = MigrationPhase.MIGRATING;
|
||||||
draft.migrateOptions = options;
|
draft.migrateOptions = options;
|
||||||
draft.migrationProgress = { total: migratableEntries.length, completed: 0, success: 0, failed: 0 };
|
|
||||||
draft.groupExpandState = MIGRATE_EXECUTE_ENTRY_GROUP_EXPAND_DEFAULT_STATE;
|
draft.groupExpandState = MIGRATE_EXECUTE_ENTRY_GROUP_EXPAND_DEFAULT_STATE;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -503,7 +496,7 @@ export class MigrationManager {
|
|||||||
try {
|
try {
|
||||||
await Promise.allSettled(migrationPromises);
|
await Promise.allSettled(migrationPromises);
|
||||||
} finally {
|
} finally {
|
||||||
const { migrationProgress } = MigrationManager.getState();
|
const migrationProgress = MigrationManager.getMigrationProgress();
|
||||||
|
|
||||||
if (migrationProgress.completed === migrationProgress.total) {
|
if (migrationProgress.completed === migrationProgress.total) {
|
||||||
MigrationManager.updateState((draft) => {
|
MigrationManager.updateState((draft) => {
|
||||||
@@ -644,7 +637,7 @@ export class MigrationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static abortEntry(mangaId: MangaIdInfo['id']): void {
|
static abortEntry(mangaId: MangaIdInfo['id']): void {
|
||||||
const { entries, phase } = MigrationManager.getState();
|
const { entries } = MigrationManager.getState();
|
||||||
const entry = entries[mangaId];
|
const entry = entries[mangaId];
|
||||||
|
|
||||||
assertIsDefined(entry);
|
assertIsDefined(entry);
|
||||||
@@ -655,12 +648,10 @@ export class MigrationManager {
|
|||||||
|
|
||||||
assertIsDefined(draftEntry);
|
assertIsDefined(draftEntry);
|
||||||
|
|
||||||
draftEntry.status = MigrationEntryStatus.ABORTED;
|
if (draftEntry.status === MigrationEntryStatus.SEARCHING) {
|
||||||
|
draftEntry.status = MigrationEntryStatus.SEARCH_ABORTED;
|
||||||
if (phase === MigrationPhase.SEARCHING) {
|
|
||||||
draft.searchProgress.completed += 1;
|
|
||||||
} else {
|
} else {
|
||||||
draft.migrationProgress.completed += 1;
|
draftEntry.status = MigrationEntryStatus.MIGRATION_ABORTED;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -673,11 +664,6 @@ export class MigrationManager {
|
|||||||
MigrationManager.updateState((draft) => {
|
MigrationManager.updateState((draft) => {
|
||||||
const entry = draft.entries[mangaId];
|
const entry = draft.entries[mangaId];
|
||||||
if (entry) {
|
if (entry) {
|
||||||
if (MigrationEntries.isSearching(entry)) {
|
|
||||||
draft.searchProgress.completed += 1;
|
|
||||||
draft.searchProgress.success += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.status = MigrationEntryStatus.SEARCH_COMPLETE;
|
entry.status = MigrationEntryStatus.SEARCH_COMPLETE;
|
||||||
entry.isManualSelection = true;
|
entry.isManualSelection = true;
|
||||||
entry.selectedMatchMangaId = targetMangaId;
|
entry.selectedMatchMangaId = targetMangaId;
|
||||||
@@ -710,8 +696,6 @@ export class MigrationManager {
|
|||||||
entry.selectedMatchSourceId = match.sourceId;
|
entry.selectedMatchSourceId = match.sourceId;
|
||||||
|
|
||||||
if (isSearching) {
|
if (isSearching) {
|
||||||
draft.searchProgress.completed += 1;
|
|
||||||
draft.searchProgress.success += 1;
|
|
||||||
MigrationManager.abortControllerByManga.get(mangaId)?.abort('Manual match selected');
|
MigrationManager.abortControllerByManga.get(mangaId)?.abort('Manual match selected');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -920,7 +904,7 @@ export class MigrationManager {
|
|||||||
const searchController = new AbortController();
|
const searchController = new AbortController();
|
||||||
const signal = AbortSignal.any([mainSignal, searchController.signal]);
|
const signal = AbortSignal.any([mainSignal, searchController.signal]);
|
||||||
|
|
||||||
if (!entry || MigrationEntries.hasStatus(entry, MigrationEntryStatus.ABORTED)) {
|
if (!entry || MigrationEntries.hasStatus(entry, MigrationEntryStatus.SEARCH_ABORTED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,14 +1069,11 @@ export class MigrationManager {
|
|||||||
if (draftEntry.selectedMatchMangaId != null) {
|
if (draftEntry.selectedMatchMangaId != null) {
|
||||||
draftEntry.status = MigrationEntryStatus.SEARCH_COMPLETE;
|
draftEntry.status = MigrationEntryStatus.SEARCH_COMPLETE;
|
||||||
} else {
|
} else {
|
||||||
draftEntry.status = MigrationEntryStatus.OUTDATED;
|
draftEntry.status = MigrationEntryStatus.SEARCH_OUTDATED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draftEntry.status = MigrationEntryStatus.NO_MATCH;
|
draftEntry.status = MigrationEntryStatus.SEARCH_NO_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
draft.searchProgress.success += 1;
|
|
||||||
draft.searchProgress.completed += 1;
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (mainSignal.aborted) {
|
if (mainSignal.aborted) {
|
||||||
@@ -1102,11 +1083,9 @@ export class MigrationManager {
|
|||||||
MigrationManager.updateState((draft) => {
|
MigrationManager.updateState((draft) => {
|
||||||
const draftEntry = draft.entries[mangaId];
|
const draftEntry = draft.entries[mangaId];
|
||||||
|
|
||||||
if (!MigrationEntries.hasStatus(draftEntry, MigrationEntryStatus.ABORTED)) {
|
if (!MigrationEntries.hasStatus(draftEntry, MigrationEntryStatus.SEARCH_ABORTED)) {
|
||||||
draftEntry.status = MigrationEntryStatus.SEARCH_FAILED;
|
draftEntry.status = MigrationEntryStatus.SEARCH_FAILED;
|
||||||
draftEntry.error = getErrorMessage(error);
|
draftEntry.error = getErrorMessage(error);
|
||||||
draft.searchProgress.completed += 1;
|
|
||||||
draft.searchProgress.failed += 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1129,7 +1108,7 @@ export class MigrationManager {
|
|||||||
!entry ||
|
!entry ||
|
||||||
!entry.selectedMatchSourceId ||
|
!entry.selectedMatchSourceId ||
|
||||||
entry.selectedMatchMangaId == null ||
|
entry.selectedMatchMangaId == null ||
|
||||||
MigrationEntries.hasStatus(entry, MigrationEntryStatus.ABORTED)
|
MigrationEntries.hasStatus(entry, MigrationEntryStatus.MIGRATION_ABORTED)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1166,8 +1145,6 @@ export class MigrationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draft.entries[mangaId].status = MigrationEntryStatus.MIGRATION_COMPLETE;
|
draft.entries[mangaId].status = MigrationEntryStatus.MIGRATION_COMPLETE;
|
||||||
draft.migrationProgress.success += 1;
|
|
||||||
draft.migrationProgress.completed += 1;
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (mainSignal.aborted) {
|
if (mainSignal.aborted) {
|
||||||
@@ -1179,11 +1156,9 @@ export class MigrationManager {
|
|||||||
|
|
||||||
assertIsDefined(draftEntry);
|
assertIsDefined(draftEntry);
|
||||||
|
|
||||||
if (!MigrationEntries.hasStatus(draftEntry, MigrationEntryStatus.ABORTED)) {
|
if (!MigrationEntries.hasStatus(draftEntry, MigrationEntryStatus.MIGRATION_ABORTED)) {
|
||||||
draftEntry.status = MigrationEntryStatus.MIGRATION_FAILED;
|
draftEntry.status = MigrationEntryStatus.MIGRATION_FAILED;
|
||||||
draftEntry.error = getErrorMessage(error);
|
draftEntry.error = getErrorMessage(error);
|
||||||
draft.migrationProgress.failed += 1;
|
|
||||||
draft.migrationProgress.completed += 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1206,8 +1181,6 @@ export class MigrationManager {
|
|||||||
const draftEntry = draft.entries[id];
|
const draftEntry = draft.entries[id];
|
||||||
draftEntry.status = MigrationEntryStatus.SEARCH_PENDING;
|
draftEntry.status = MigrationEntryStatus.SEARCH_PENDING;
|
||||||
draftEntry.error = undefined;
|
draftEntry.error = undefined;
|
||||||
draft.searchProgress.completed -= 1;
|
|
||||||
draft.searchProgress.failed -= 1;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
assertIsDefined(searchOptions);
|
assertIsDefined(searchOptions);
|
||||||
@@ -1224,8 +1197,6 @@ export class MigrationManager {
|
|||||||
const draftEntry = draft.entries[id];
|
const draftEntry = draft.entries[id];
|
||||||
draftEntry.status = MigrationEntryStatus.MIGRATION_PENDING;
|
draftEntry.status = MigrationEntryStatus.MIGRATION_PENDING;
|
||||||
draftEntry.error = undefined;
|
draftEntry.error = undefined;
|
||||||
draft.migrationProgress.completed -= 1;
|
|
||||||
draft.migrationProgress.failed -= 1;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
assertIsDefined(migrateOptions);
|
assertIsDefined(migrateOptions);
|
||||||
@@ -1256,6 +1227,45 @@ export class MigrationManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static getSearchProgress(state: MigrationState = MigrationManager.getState()): MigrationProgress {
|
||||||
|
const entries = Object.values(state.entries);
|
||||||
|
|
||||||
|
const success = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.SEARCH_COMPLETE).length;
|
||||||
|
const failed = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.SEARCH_FAILED).length;
|
||||||
|
const noMatch = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.SEARCH_NO_MATCH).length;
|
||||||
|
const aborted = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.SEARCH_ABORTED).length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
total: entries.length,
|
||||||
|
completed: success + failed + noMatch + aborted,
|
||||||
|
success,
|
||||||
|
failed,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getMigrationProgress(state: MigrationState = MigrationManager.getState()): MigrationProgress {
|
||||||
|
const entries = Object.values(state.entries);
|
||||||
|
|
||||||
|
const total = MigrationEntries.getHaveStatus(
|
||||||
|
entries,
|
||||||
|
MigrationEntryStatus.MIGRATION_ABORTED,
|
||||||
|
MigrationEntryStatus.MIGRATION_PENDING,
|
||||||
|
MigrationEntryStatus.MIGRATION_FAILED,
|
||||||
|
MigrationEntryStatus.MIGRATION_COMPLETE,
|
||||||
|
).length;
|
||||||
|
|
||||||
|
const success = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.MIGRATION_COMPLETE).length;
|
||||||
|
const failed = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.MIGRATION_FAILED).length;
|
||||||
|
const aborted = MigrationEntries.getHaveStatus(entries, MigrationEntryStatus.MIGRATION_ABORTED).length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
total,
|
||||||
|
completed: success + failed + aborted,
|
||||||
|
success,
|
||||||
|
failed,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static useEntryMatchesExpandState(id: MangaIdInfo['id']): boolean {
|
static useEntryMatchesExpandState(id: MangaIdInfo['id']): boolean {
|
||||||
return useMigrationStore((state) => state.entries[id]?.areMatchesExpanded ?? false);
|
return useMigrationStore((state) => state.entries[id]?.areMatchesExpanded ?? false);
|
||||||
}
|
}
|
||||||
@@ -1282,12 +1292,12 @@ export class MigrationManager {
|
|||||||
return useMigrationStore((state) => state.entries);
|
return useMigrationStore((state) => state.entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static useSearchProgress(): MigrationState['searchProgress'] {
|
static useSearchProgress(): MigrationProgress {
|
||||||
return useMigrationStore((state) => state.searchProgress);
|
return useMigrationStore((state) => MigrationManager.getSearchProgress(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static useMigrationProgress(): MigrationState['migrationProgress'] {
|
static useMigrationProgress(): MigrationProgress {
|
||||||
return useMigrationStore((state) => state.migrationProgress);
|
return useMigrationStore((state) => MigrationManager.getMigrationProgress(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static useIsActive(): boolean {
|
static useIsActive(): boolean {
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ const EntryStatus = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack sx={{ alignItems: 'center', justifyContent: 'center', gap: 2 }}>
|
<Stack sx={{ alignItems: 'center', justifyContent: 'center', gap: 2 }}>
|
||||||
<Typography color={status === MigrationEntryStatus.NO_MATCH ? 'warning' : undefined}>
|
<Typography color={status === MigrationEntryStatus.SEARCH_NO_MATCH ? 'warning' : undefined}>
|
||||||
{t(ENTRY_STATUS_TRANSLATION[status])}
|
{t(ENTRY_STATUS_TRANSLATION[status])}
|
||||||
</Typography>
|
</Typography>
|
||||||
{!isMigrating && status === MigrationEntryStatus.NO_MATCH && (
|
{!isMigrating && status === MigrationEntryStatus.SEARCH_NO_MATCH && (
|
||||||
<Button
|
<Button
|
||||||
startIcon={<SearchIcon />}
|
startIcon={<SearchIcon />}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const MigrationEntryStatusIndicator = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status === MigrationEntryStatus.NO_MATCH) {
|
if (status === MigrationEntryStatus.SEARCH_NO_MATCH) {
|
||||||
return (
|
return (
|
||||||
<StatusIndicatorWrapper
|
<StatusIndicatorWrapper
|
||||||
backgroundColor={(theme) => theme.palette.warning.main}
|
backgroundColor={(theme) => theme.palette.warning.main}
|
||||||
|
|||||||
@@ -64,16 +64,16 @@ export const MigrationExecute = () => {
|
|||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const abortedEntries = useMemo(
|
const abortedEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.ABORTED),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.MIGRATION_ABORTED),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const excludedEntries = useMemo(() => MigrationEntries.getExcluded(entryList), [entryList]);
|
const excludedEntries = useMemo(() => MigrationEntries.getExcluded(entryList), [entryList]);
|
||||||
const noMatchEntries = useMemo(
|
const noMatchEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.NO_MATCH),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.SEARCH_NO_MATCH),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const outdatedEntries = useMemo(
|
const outdatedEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.OUTDATED),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.SEARCH_OUTDATED),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ export const MigrationExecute = () => {
|
|||||||
color="error"
|
color="error"
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.ABORTED}
|
status={MigrationEntryStatus.MIGRATION_ABORTED}
|
||||||
title={plural(abortedEntries.length, {
|
title={plural(abortedEntries.length, {
|
||||||
one: '1 aborted entry',
|
one: '1 aborted entry',
|
||||||
other: '# aborted entries',
|
other: '# aborted entries',
|
||||||
@@ -122,7 +122,7 @@ export const MigrationExecute = () => {
|
|||||||
isAborted={MigrationManager.getState().isAborted}
|
isAborted={MigrationManager.getState().isAborted}
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.NO_MATCH}
|
status={MigrationEntryStatus.SEARCH_NO_MATCH}
|
||||||
title={plural(noMatchEntries.length, {
|
title={plural(noMatchEntries.length, {
|
||||||
one: '1 entry with no match',
|
one: '1 entry with no match',
|
||||||
other: '# entries with no match',
|
other: '# entries with no match',
|
||||||
@@ -133,7 +133,7 @@ export const MigrationExecute = () => {
|
|||||||
isAborted={MigrationManager.getState().isAborted}
|
isAborted={MigrationManager.getState().isAborted}
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.OUTDATED}
|
status={MigrationEntryStatus.SEARCH_OUTDATED}
|
||||||
title={plural(outdatedEntries.length, {
|
title={plural(outdatedEntries.length, {
|
||||||
one: '1 entry with only outdated matches',
|
one: '1 entry with only outdated matches',
|
||||||
other: '# entries with only outdated matches',
|
other: '# entries with only outdated matches',
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ export const MigrationSearch = () => {
|
|||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const noMatchEntries = useMemo(
|
const noMatchEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.NO_MATCH),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.SEARCH_NO_MATCH),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const outdatedEntries = useMemo(
|
const outdatedEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.OUTDATED),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.SEARCH_OUTDATED),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const abortedEntries = useMemo(
|
const abortedEntries = useMemo(
|
||||||
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.ABORTED),
|
() => MigrationEntries.getHaveStatusSorted(entryList, MigrationEntryStatus.SEARCH_ABORTED),
|
||||||
[entryList],
|
[entryList],
|
||||||
);
|
);
|
||||||
const matchedEntries = useMemo(
|
const matchedEntries = useMemo(
|
||||||
@@ -95,7 +95,7 @@ export const MigrationSearch = () => {
|
|||||||
color="error"
|
color="error"
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.NO_MATCH}
|
status={MigrationEntryStatus.SEARCH_NO_MATCH}
|
||||||
title={plural(noMatchEntries.length, {
|
title={plural(noMatchEntries.length, {
|
||||||
one: '1 entry with no match',
|
one: '1 entry with no match',
|
||||||
other: '# entries with no match',
|
other: '# entries with no match',
|
||||||
@@ -104,7 +104,7 @@ export const MigrationSearch = () => {
|
|||||||
color="warning"
|
color="warning"
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.OUTDATED}
|
status={MigrationEntryStatus.SEARCH_OUTDATED}
|
||||||
title={plural(outdatedEntries.length, {
|
title={plural(outdatedEntries.length, {
|
||||||
one: '1 entry with only outdated matches',
|
one: '1 entry with only outdated matches',
|
||||||
other: '# entries with only outdated matches',
|
other: '# entries with only outdated matches',
|
||||||
@@ -113,7 +113,7 @@ export const MigrationSearch = () => {
|
|||||||
color="warning"
|
color="warning"
|
||||||
/>
|
/>
|
||||||
<MigrationEntryGroup
|
<MigrationEntryGroup
|
||||||
status={MigrationEntryStatus.ABORTED}
|
status={MigrationEntryStatus.SEARCH_ABORTED}
|
||||||
title={plural(abortedEntries.length, {
|
title={plural(abortedEntries.length, {
|
||||||
one: '1 aborted entry',
|
one: '1 aborted entry',
|
||||||
other: '# aborted entries',
|
other: '# aborted entries',
|
||||||
|
|||||||
Reference in New Issue
Block a user