mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
fix(web): show warning if upload completed with errors (#3634)
This commit is contained in:
parent
a815592954
commit
a8b01dc21a
@ -10,6 +10,7 @@
|
|||||||
let showDetail = true;
|
let showDetail = true;
|
||||||
let uploadLength = 0;
|
let uploadLength = 0;
|
||||||
let duplicateCount = 0;
|
let duplicateCount = 0;
|
||||||
|
let errorCount = 0;
|
||||||
let isUploading = false;
|
let isUploading = false;
|
||||||
|
|
||||||
// Reactive action to update asset uploadLength whenever there is a new one added to the list
|
// Reactive action to update asset uploadLength whenever there is a new one added to the list
|
||||||
@ -26,6 +27,10 @@
|
|||||||
uploadAssetsStore.duplicateCounter.subscribe((value) => {
|
uploadAssetsStore.duplicateCounter.subscribe((value) => {
|
||||||
duplicateCount = value;
|
duplicateCount = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
uploadAssetsStore.errorCounter.subscribe((value) => {
|
||||||
|
errorCount = value;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isUploading}
|
{#if isUploading}
|
||||||
@ -33,10 +38,17 @@
|
|||||||
in:fade={{ duration: 250 }}
|
in:fade={{ duration: 250 }}
|
||||||
out:fade={{ duration: 250, delay: 1000 }}
|
out:fade={{ duration: 250, delay: 1000 }}
|
||||||
on:outroend={() => {
|
on:outroend={() => {
|
||||||
|
const errorInfo =
|
||||||
|
errorCount > 0 ? `Upload completed with ${errorCount} error${errorCount > 1 ? 's' : ''}` : 'Upload success';
|
||||||
|
const type = errorCount > 0 ? NotificationType.Warning : NotificationType.Info;
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: 'Upload success, refresh the page to see new upload assets',
|
message: `${errorInfo}, refresh the page to see new upload assets`,
|
||||||
type: NotificationType.Info,
|
type,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
uploadAssetsStore.errorCounter.set(0);
|
||||||
|
|
||||||
if (duplicateCount > 0) {
|
if (duplicateCount > 0) {
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Skipped ${duplicateCount} duplicate picture${duplicateCount > 1 ? 's' : ''}`,
|
message: `Skipped ${duplicateCount} duplicate picture${duplicateCount > 1 ? 's' : ''}`,
|
||||||
|
@ -4,6 +4,7 @@ import type { UploadAsset } from '../models/upload-asset';
|
|||||||
function createUploadStore() {
|
function createUploadStore() {
|
||||||
const uploadAssets = writable<Array<UploadAsset>>([]);
|
const uploadAssets = writable<Array<UploadAsset>>([]);
|
||||||
const duplicateCounter = writable(0);
|
const duplicateCounter = writable(0);
|
||||||
|
const errorCounter = writable(0);
|
||||||
|
|
||||||
const { subscribe } = uploadAssets;
|
const { subscribe } = uploadAssets;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ function createUploadStore() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
|
errorCounter,
|
||||||
duplicateCounter,
|
duplicateCounter,
|
||||||
isUploading,
|
isUploading,
|
||||||
addNewUploadAsset,
|
addNewUploadAsset,
|
||||||
|
@ -173,6 +173,8 @@ async function fileUploader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUploadError(asset: File, respBody = '{}', extraMessage?: string) {
|
function handleUploadError(asset: File, respBody = '{}', extraMessage?: string) {
|
||||||
|
uploadAssetsStore.errorCounter.update((count) => count + 1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = JSON.parse(respBody);
|
const res = JSON.parse(respBody);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user