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

View File

@@ -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>

View File

@@ -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];

View File

@@ -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,
});
}
}

View File

@@ -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={[