mirror of
https://github.com/immich-app/immich.git
synced 2026-03-27 20:30:45 +03:00
refactor: split delete event into two
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType));
|
||||
|
||||
function onIntegrityReportDelete({
|
||||
function onIntegrityReportDeleteStatus({
|
||||
id: reportId,
|
||||
type,
|
||||
isDeleting,
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<OnEvents {onIntegrityReportDelete} />
|
||||
<OnEvents {onIntegrityReportDeleteStatus} />
|
||||
|
||||
<TableRow>
|
||||
<TableCell class="w-7/8 text-left px-4">{path}</TableCell>
|
||||
|
||||
@@ -65,7 +65,8 @@ export type Events = {
|
||||
|
||||
SystemConfigUpdate: [SystemConfigDto];
|
||||
|
||||
IntegrityReportDelete: [{ type?: IntegrityReportType; id?: string; isDeleting: boolean; isDeleted: boolean }];
|
||||
IntegrityReportDeleteStatus: [{ type?: IntegrityReportType; id?: string; isDeleting: boolean }];
|
||||
IntegrityReportDeleted: [{ type?: IntegrityReportType; id?: string }];
|
||||
|
||||
LibraryCreate: [LibraryResponseDto];
|
||||
LibraryUpdate: [LibraryResponseDto];
|
||||
|
||||
@@ -89,27 +89,23 @@ export const handleRemoveAllIntegrityReportItems = async (reportType: IntegrityR
|
||||
}
|
||||
|
||||
try {
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||
type: reportType,
|
||||
isDeleting: true,
|
||||
isDeleted: false,
|
||||
});
|
||||
|
||||
await createJob({ jobCreateDto: { name } });
|
||||
toastManager.success($t('admin.job_created'));
|
||||
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleted', {
|
||||
type: reportType,
|
||||
isDeleting: false,
|
||||
isDeleted: true,
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error, $t('failed_to_delete_file'));
|
||||
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||
type: reportType,
|
||||
isDeleting: false,
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -123,28 +119,24 @@ export const handleRemoveIntegrityReportItem = async (reportId: string) => {
|
||||
|
||||
if (confirm) {
|
||||
try {
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||
id: reportId,
|
||||
isDeleting: true,
|
||||
isDeleted: false,
|
||||
});
|
||||
|
||||
await deleteIntegrityReport({
|
||||
id: reportId,
|
||||
});
|
||||
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleted', {
|
||||
id: reportId,
|
||||
isDeleting: false,
|
||||
isDeleted: true,
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error, $t('failed_to_delete_file'));
|
||||
|
||||
eventManager.emit('IntegrityReportDelete', {
|
||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||
id: reportId,
|
||||
isDeleting: false,
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,19 +58,7 @@
|
||||
|
||||
const { Download, Delete } = $derived(getIntegrityReportActions($t, data.type));
|
||||
|
||||
function onIntegrityReportDelete({
|
||||
id,
|
||||
type,
|
||||
isDeleted,
|
||||
}: {
|
||||
id?: string;
|
||||
type?: IntegrityReportType;
|
||||
isDeleted: boolean;
|
||||
}) {
|
||||
if (!isDeleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
function onIntegrityReportDeleted({ id, type }: { id?: string; type?: IntegrityReportType }) {
|
||||
if (type === data.type) {
|
||||
integrityReport.items = [];
|
||||
integrityReport.nextCursor = undefined;
|
||||
@@ -80,7 +68,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<OnEvents {onIntegrityReportDelete} />
|
||||
<OnEvents {onIntegrityReportDeleted} />
|
||||
|
||||
<AdminPageLayout
|
||||
breadcrumbs={[
|
||||
|
||||
Reference in New Issue
Block a user