From a9d0be43f50f687bf7bfb286848db1d08d0bd844 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Fri, 26 Jan 2024 14:24:12 +0100 Subject: [PATCH] improve web --- web/src/lib/utils/asset-utils.ts | 5 ++--- web/src/lib/utils/file-uploader.ts | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/web/src/lib/utils/asset-utils.ts b/web/src/lib/utils/asset-utils.ts index 2b95f3f8ca..9f67059dfd 100644 --- a/web/src/lib/utils/asset-utils.ts +++ b/web/src/lib/utils/asset-utils.ts @@ -11,7 +11,6 @@ import { } from '@api'; import { handleError } from './handle-error'; import { DateTime } from 'luxon'; -import type { AxiosProgressEvent } from 'axios'; export const addAssetsToAlbum = async (albumId: string, assetIds: Array): Promise => api.albumApi @@ -126,8 +125,8 @@ export const downloadFile = async (asset: AssetResponseDto) => { { id, key: api.getKey() }, { responseType: 'blob', - onDownloadProgress: (event: AxiosProgressEvent) => { - if (event.total !== undefined) { + onDownloadProgress: ({ event }) => { + if (event.lengthComputable) { downloadManager.update(downloadKey, event.loaded, event.total); } }, diff --git a/web/src/lib/utils/file-uploader.ts b/web/src/lib/utils/file-uploader.ts index e915d7991f..5e47b156f0 100644 --- a/web/src/lib/utils/file-uploader.ts +++ b/web/src/lib/utils/file-uploader.ts @@ -83,10 +83,9 @@ async function fileUploader(asset: File, albumId: string | undefined = undefined key: api.getKey(), }, { - onUploadProgress: ({ loaded, total }) => { - if (total) { - uploadAssetsStore.updateProgress(deviceAssetId, loaded, total); - } + onUploadProgress: ({ event }) => { + const { loaded, total } = event; + uploadAssetsStore.updateProgress(deviceAssetId, loaded, total); }, }, ),