refactor: arrow functions in svelte components

fix: should provide arrow function to , oops!

Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
izzy
2026-02-12 11:43:17 +00:00
parent 4908289879
commit bf17d8cbd1
4 changed files with 13 additions and 12 deletions
@@ -16,7 +16,7 @@
const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType)); const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType));
function onIntegrityReportDeleteStatus({ const onIntegrityReportDeleteStatus = ({
id: reportId, id: reportId,
type, type,
isDeleting, isDeleting,
@@ -24,11 +24,11 @@
id?: string; id?: string;
type?: IntegrityReportType; type?: IntegrityReportType;
isDeleting: boolean; isDeleting: boolean;
}) { }) => {
if (type === reportType || reportId === id) { if (type === reportType || reportId === id) {
deleting = isDeleting; deleting = isDeleting;
} }
} };
</script> </script>
<OnEvents {onIntegrityReportDeleteStatus} /> <OnEvents {onIntegrityReportDeleteStatus} />
+3 -3
View File
@@ -34,16 +34,16 @@ export const getIntegrityReportItemActions = (
reportId: string, reportId: string,
reportType: IntegrityReportType, reportType: IntegrityReportType,
) => { ) => {
const Download = { const Download: ActionItem = {
title: $t('download'), title: $t('download'),
icon: mdiDownload, icon: mdiDownload,
onAction: () => { onAction: () => {
void handleDownloadIntegrityReportFile(reportId); void handleDownloadIntegrityReportFile(reportId);
}, },
$if: reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch, $if: () => reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch,
}; };
const Delete = { const Delete: ActionItem = {
title: $t('delete'), title: $t('delete'),
icon: mdiTrashCanOutline, icon: mdiTrashCanOutline,
color: 'danger', color: 'danger',
@@ -32,6 +32,7 @@
const { data }: Props = $props(); const { data }: Props = $props();
const { StartMaintenance } = $derived(getMaintenanceAdminActions($t)); const { StartMaintenance } = $derived(getMaintenanceAdminActions($t));
// svelte-ignore state_referenced_locally
let integrityReport: IntegrityReportSummaryResponseDto = $state(data.integrityReport); let integrityReport: IntegrityReportSummaryResponseDto = $state(data.integrityReport);
const TYPES: IntegrityReportType[] = [ const TYPES: IntegrityReportType[] = [
@@ -75,7 +76,7 @@
running = false; running = false;
}); });
function onJobCreate({ dto }: { dto: JobCreateDto }) { const onJobCreate = ({ dto }: { dto: JobCreateDto }) => {
if ( if (
(Object.values(INTEGRITY_JOB_NAMES).includes(dto.name) || (Object.values(INTEGRITY_JOB_NAMES).includes(dto.name) ||
Object.values(INTEGRITY_REFRESH_JOB_NAMES).includes(dto.name)) && Object.values(INTEGRITY_REFRESH_JOB_NAMES).includes(dto.name)) &&
@@ -84,7 +85,7 @@
expectingUpdate = true; expectingUpdate = true;
jobs.integrityCheck.queueStatus.isActive = true; jobs.integrityCheck.queueStatus.isActive = true;
} }
} };
</script> </script>
<OnEvents {onJobCreate} /> <OnEvents {onJobCreate} />
@@ -20,7 +20,7 @@
// svelte-ignore state_referenced_locally // svelte-ignore state_referenced_locally
let integrityReport = $state(data.integrityReport); let integrityReport = $state(data.integrityReport);
async function loadMore() { const loadMore = async () => {
const { items, nextCursor } = await getIntegrityReport({ const { items, nextCursor } = await getIntegrityReport({
$type: data.type, $type: data.type,
cursor: integrityReport.nextCursor, cursor: integrityReport.nextCursor,
@@ -28,7 +28,7 @@
integrityReport.items.push(...items); integrityReport.items.push(...items);
integrityReport.nextCursor = nextCursor; integrityReport.nextCursor = nextCursor;
} };
let running = true; let running = true;
let expectingUpdate = false; let expectingUpdate = false;
@@ -55,14 +55,14 @@
const { Download, Delete } = $derived(getIntegrityReportActions($t, data.type)); const { Download, Delete } = $derived(getIntegrityReportActions($t, data.type));
function onIntegrityReportDeleted({ id, type }: { id?: string; type?: IntegrityReportType }) { const onIntegrityReportDeleted = ({ id, type }: { id?: string; type?: IntegrityReportType }) => {
if (type === data.type) { if (type === data.type) {
integrityReport.items = []; integrityReport.items = [];
integrityReport.nextCursor = undefined; integrityReport.nextCursor = undefined;
} else { } else {
integrityReport.items = integrityReport.items.filter((report) => report.id !== id); integrityReport.items = integrityReport.items.filter((report) => report.id !== id);
} }
} };
</script> </script>
<OnEvents {onIntegrityReportDeleted} /> <OnEvents {onIntegrityReportDeleted} />