From 67c241e4c43ad159efd883df682ea901089dcdae Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Fri, 19 Jan 2024 20:04:00 +0000 Subject: [PATCH] :bug: fix 'delete budget' button always deleting cloud file (#2251) Closes #2216 --- .../src/components/manager/DeleteFile.tsx | 30 +++++++++++-------- upcoming-release-notes/2251.md | 6 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 upcoming-release-notes/2251.md diff --git a/packages/desktop-client/src/components/manager/DeleteFile.tsx b/packages/desktop-client/src/components/manager/DeleteFile.tsx index c8dff180cbd..29c3875b80b 100644 --- a/packages/desktop-client/src/components/manager/DeleteFile.tsx +++ b/packages/desktop-client/src/components/manager/DeleteFile.tsx @@ -26,17 +26,6 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) { null, ); - async function onDelete() { - setLoadingState(isCloudFile ? 'cloud' : 'local'); - await actions.deleteBudget( - 'id' in file ? file.id : undefined, - isCloudFile ? file.cloudFileId : undefined, - ); - setLoadingState(null); - - modalProps.onBack(); - } - return ( { + setLoadingState('cloud'); + await actions.deleteBudget( + 'id' in file ? file.id : undefined, + file.cloudFileId, + ); + setLoadingState(null); + + modalProps.onBack(); + }} > Delete file from all devices @@ -125,7 +123,13 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) { backgroundColor: theme.errorText, }), }} - onClick={onDelete} + onClick={async () => { + setLoadingState('local'); + await actions.deleteBudget(file.id); + setLoadingState(null); + + modalProps.onBack(); + }} > Delete file locally diff --git a/upcoming-release-notes/2251.md b/upcoming-release-notes/2251.md new file mode 100644 index 00000000000..145d3e73021 --- /dev/null +++ b/upcoming-release-notes/2251.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Fix 'delete file' button always deleting the cloud file.