refactor: split delete event into two

This commit is contained in:
izzy
2026-01-13 14:56:44 +00:00
parent 69b2e36a38
commit 1c73f7f433
4 changed files with 12 additions and 31 deletions
@@ -16,7 +16,7 @@
const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType)); const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType));
function onIntegrityReportDelete({ function onIntegrityReportDeleteStatus({
id: reportId, id: reportId,
type, type,
isDeleting, isDeleting,
@@ -31,7 +31,7 @@
} }
</script> </script>
<OnEvents {onIntegrityReportDelete} /> <OnEvents {onIntegrityReportDeleteStatus} />
<TableRow> <TableRow>
<TableCell class="w-7/8 text-left px-4">{path}</TableCell> <TableCell class="w-7/8 text-left px-4">{path}</TableCell>
+2 -1
View File
@@ -65,7 +65,8 @@ export type Events = {
SystemConfigUpdate: [SystemConfigDto]; 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]; LibraryCreate: [LibraryResponseDto];
LibraryUpdate: [LibraryResponseDto]; LibraryUpdate: [LibraryResponseDto];
+6 -14
View File
@@ -89,27 +89,23 @@ export const handleRemoveAllIntegrityReportItems = async (reportType: IntegrityR
} }
try { try {
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleteStatus', {
type: reportType, type: reportType,
isDeleting: true, isDeleting: true,
isDeleted: false,
}); });
await createJob({ jobCreateDto: { name } }); await createJob({ jobCreateDto: { name } });
toastManager.success($t('admin.job_created')); toastManager.success($t('admin.job_created'));
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleted', {
type: reportType, type: reportType,
isDeleting: false,
isDeleted: true,
}); });
} catch (error) { } catch (error) {
handleError(error, $t('failed_to_delete_file')); handleError(error, $t('failed_to_delete_file'));
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleteStatus', {
type: reportType, type: reportType,
isDeleting: false, isDeleting: false,
isDeleted: false,
}); });
} }
} }
@@ -123,28 +119,24 @@ export const handleRemoveIntegrityReportItem = async (reportId: string) => {
if (confirm) { if (confirm) {
try { try {
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleteStatus', {
id: reportId, id: reportId,
isDeleting: true, isDeleting: true,
isDeleted: false,
}); });
await deleteIntegrityReport({ await deleteIntegrityReport({
id: reportId, id: reportId,
}); });
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleted', {
id: reportId, id: reportId,
isDeleting: false,
isDeleted: true,
}); });
} catch (error) { } catch (error) {
handleError(error, $t('failed_to_delete_file')); handleError(error, $t('failed_to_delete_file'));
eventManager.emit('IntegrityReportDelete', { eventManager.emit('IntegrityReportDeleteStatus', {
id: reportId, id: reportId,
isDeleting: false, isDeleting: false,
isDeleted: false,
}); });
} }
} }
@@ -58,19 +58,7 @@
const { Download, Delete } = $derived(getIntegrityReportActions($t, data.type)); const { Download, Delete } = $derived(getIntegrityReportActions($t, data.type));
function onIntegrityReportDelete({ function onIntegrityReportDeleted({ id, type }: { id?: string; type?: IntegrityReportType }) {
id,
type,
isDeleted,
}: {
id?: string;
type?: IntegrityReportType;
isDeleted: boolean;
}) {
if (!isDeleted) {
return;
}
if (type === data.type) { if (type === data.type) {
integrityReport.items = []; integrityReport.items = [];
integrityReport.nextCursor = undefined; integrityReport.nextCursor = undefined;
@@ -80,7 +68,7 @@
} }
</script> </script>
<OnEvents {onIntegrityReportDelete} /> <OnEvents {onIntegrityReportDeleted} />
<AdminPageLayout <AdminPageLayout
breadcrumbs={[ breadcrumbs={[