fix: auto update on download/file actions

This commit is contained in:
Fredrik Burmester
2025-10-03 07:57:45 +02:00
parent c36cd66e36
commit 7fef2ed5e2
4 changed files with 30 additions and 5 deletions

View File

@@ -41,6 +41,7 @@ interface UseDownloadEventHandlersProps {
) => void;
removeProcess: (id: string) => void;
onSuccess?: () => void;
onDataChange?: () => void;
api?: Api;
}
@@ -53,6 +54,7 @@ export function useDownloadEventHandlers({
updateProcess,
removeProcess,
onSuccess,
onDataChange,
api,
}: UseDownloadEventHandlersProps) {
const { t } = useTranslation();
@@ -235,6 +237,7 @@ export function useDownloadEventHandlers({
);
onSuccess?.();
onDataChange?.();
// Clean up speed data when download completes
clearSpeedData(processId);
@@ -259,6 +262,7 @@ export function useDownloadEventHandlers({
updateProcess,
removeProcess,
onSuccess,
onDataChange,
api,
saveImage,
saveSeriesPrimaryImage,

View File

@@ -32,6 +32,7 @@ interface UseDownloadOperationsProps {
removeProcess: (id: string) => void;
api: any;
authHeader?: string;
onDataChange?: () => void;
}
/**
@@ -44,6 +45,7 @@ export function useDownloadOperations({
removeProcess,
api,
authHeader,
onDataChange,
}: UseDownloadOperationsProps) {
const { t } = useTranslation();
const { saveSeriesPrimaryImage } = useDownloadHelper();
@@ -182,12 +184,13 @@ export function useDownloadOperations({
item: itemToDelete.item.Name,
}),
);
onDataChange?.();
} catch (error) {
console.error("Failed to delete files:", error);
}
}
},
[t],
[t, onDataChange],
);
const deleteItems = useCallback(
@@ -212,7 +215,8 @@ export function useDownloadOperations({
clearAllDownloadedItems();
toast.success(t("home.downloads.toasts.all_files_deleted"));
}, [t]);
onDataChange?.();
}, [t, onDataChange]);
const deleteFileByType = useCallback(
async (itemType: string) => {
@@ -256,8 +260,10 @@ export function useDownloadOperations({
defaultValue: `${itemsToDelete.length} ${itemLabel} deleted`,
}),
);
onDataChange?.();
},
[t],
[t, onDataChange],
);
const appSizeUsage = useCallback(async () => {