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

View File

@@ -16,7 +16,7 @@
const { Download, Delete } = $derived(getIntegrityReportItemActions($t, id, reportType));
function onIntegrityReportDeleteStatus({
const onIntegrityReportDeleteStatus = ({
id: reportId,
type,
isDeleting,
@@ -24,11 +24,11 @@
id?: string;
type?: IntegrityReportType;
isDeleting: boolean;
}) {
}) => {
if (type === reportType || reportId === id) {
deleting = isDeleting;
}
}
};
</script>
<OnEvents {onIntegrityReportDeleteStatus} />

View File

@@ -34,16 +34,16 @@ export const getIntegrityReportItemActions = (
reportId: string,
reportType: IntegrityReportType,
) => {
const Download = {
const Download: ActionItem = {
title: $t('download'),
icon: mdiDownload,
onAction: () => {
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'),
icon: mdiTrashCanOutline,
color: 'danger',

View File

@@ -32,6 +32,7 @@
const { data }: Props = $props();
const { StartMaintenance } = $derived(getMaintenanceAdminActions($t));
// svelte-ignore state_referenced_locally
let integrityReport: IntegrityReportSummaryResponseDto = $state(data.integrityReport);
const TYPES: IntegrityReportType[] = [
@@ -75,7 +76,7 @@
running = false;
});
function onJobCreate({ dto }: { dto: JobCreateDto }) {
const onJobCreate = ({ dto }: { dto: JobCreateDto }) => {
if (
(Object.values(INTEGRITY_JOB_NAMES).includes(dto.name) ||
Object.values(INTEGRITY_REFRESH_JOB_NAMES).includes(dto.name)) &&
@@ -84,7 +85,7 @@
expectingUpdate = true;
jobs.integrityCheck.queueStatus.isActive = true;
}
}
};
</script>
<OnEvents {onJobCreate} />

View File

@@ -20,7 +20,7 @@
// svelte-ignore state_referenced_locally
let integrityReport = $state(data.integrityReport);
async function loadMore() {
const loadMore = async () => {
const { items, nextCursor } = await getIntegrityReport({
$type: data.type,
cursor: integrityReport.nextCursor,
@@ -28,7 +28,7 @@
integrityReport.items.push(...items);
integrityReport.nextCursor = nextCursor;
}
};
let running = true;
let expectingUpdate = false;
@@ -55,14 +55,14 @@
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) {
integrityReport.items = [];
integrityReport.nextCursor = undefined;
} else {
integrityReport.items = integrityReport.items.filter((report) => report.id !== id);
}
}
};
</script>
<OnEvents {onIntegrityReportDeleted} />