From a7efd66ae986dbf9194ac24cc046da99ac26610c Mon Sep 17 00:00:00 2001 From: DeclanE <160616898+declan8010@users.noreply.github.com> Date: Wed, 13 Mar 2024 01:37:56 +0000 Subject: [PATCH] fix(web): Enhance Notification Handling for Duplicate Assets (#7858) * Duplicate reporting in upload panel file-uploader.ts * Update upload-panel.svelte * Reimplement Error reporting upload-panel.svelte * Update upload-panel.svelte * Run Prettier again * Update web/src/lib/components/shared-components/upload-panel.svelte Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * Ran Prettier * Update web/src/lib/components/shared-components/upload-panel.svelte Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * Run Prettier final * Update web/src/lib/components/shared-components/upload-panel.svelte Removed odd "``;" Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> --------- Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Co-authored-by: Alex Tran --- .../shared-components/upload-panel.svelte | 20 ++++++++++--------- web/src/lib/utils/file-uploader.ts | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/web/src/lib/components/shared-components/upload-panel.svelte b/web/src/lib/components/shared-components/upload-panel.svelte index 6aa90b6a7f..bbcba662b3 100644 --- a/web/src/lib/components/shared-components/upload-panel.svelte +++ b/web/src/lib/components/shared-components/upload-panel.svelte @@ -34,21 +34,23 @@ in:fade={{ duration: 250 }} out:fade={{ duration: 250 }} on:outroend={() => { - notificationController.show({ - message: - ($errorCounter > 0 - ? `Upload completed with ${$errorCounter} error${$errorCounter > 1 ? 's' : ''}` - : 'Upload success') + ', refresh the page to see new upload assets.', - type: $errorCounter > 0 ? NotificationType.Warning : NotificationType.Info, - }); - + if ($errorCounter > 0) { + notificationController.show({ + message: `Upload completed with ${$errorCounter} error${$errorCounter > 1 ? 's' : ''}, refresh the page to see new upload assets.`, + type: NotificationType.Warning, + }); + } else if ($successCounter > 0) { + notificationController.show({ + message: 'Upload success, refresh the page to see new upload assets.', + type: NotificationType.Info, + }); + } if ($duplicateCounter > 0) { notificationController.show({ message: `Skipped ${$duplicateCounter} duplicate asset${$duplicateCounter > 1 ? 's' : ''}`, type: NotificationType.Warning, }); } - uploadAssetsStore.resetStore(); }} class="absolute bottom-6 right-6 z-[10000]" diff --git a/web/src/lib/utils/file-uploader.ts b/web/src/lib/utils/file-uploader.ts index c53d6e2a8b..fbfc1abc60 100644 --- a/web/src/lib/utils/file-uploader.ts +++ b/web/src/lib/utils/file-uploader.ts @@ -99,6 +99,8 @@ async function fileUploader(asset: File, albumId: string | undefined = undefined if (res.duplicate) { uploadAssetsStore.duplicateCounter.update((count) => count + 1); + } else { + uploadAssetsStore.successCounter.update((c) => c + 1); } if (albumId && res.id) { @@ -110,7 +112,6 @@ async function fileUploader(asset: File, albumId: string | undefined = undefined uploadAssetsStore.updateAsset(deviceAssetId, { state: res.duplicate ? UploadState.DUPLICATED : UploadState.DONE, }); - uploadAssetsStore.successCounter.update((c) => c + 1); setTimeout(() => { uploadAssetsStore.removeUploadAsset(deviceAssetId);