1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00

fix(web): show duplicate message (#9992)

This commit is contained in:
Jason Rasmussen 2024-06-05 09:29:52 -04:00 committed by GitHub
parent 97ffddee7c
commit cf223dc98c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -123,8 +123,6 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
} }
} }
let status;
let id;
if (!responseData) { if (!responseData) {
uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Uploading...' }); uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Uploading...' });
if (replaceAssetId) { if (replaceAssetId) {
@ -134,7 +132,7 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
data: formData, data: formData,
onUploadProgress: (event) => uploadAssetsStore.updateProgress(deviceAssetId, event.loaded, event.total), onUploadProgress: (event) => uploadAssetsStore.updateProgress(deviceAssetId, event.loaded, event.total),
}); });
({ status, id } = response.data); responseData = response.data;
} else { } else {
const response = await uploadRequest<AssetMediaResponseDto>({ const response = await uploadRequest<AssetMediaResponseDto>({
url: getBaseUrl() + '/assets' + (key ? `?key=${key}` : ''), url: getBaseUrl() + '/assets' + (key ? `?key=${key}` : ''),
@ -146,30 +144,31 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
throw new Error('Failed to upload file'); throw new Error('Failed to upload file');
} }
({ status, id } = response.data); responseData = response.data;
} }
} }
if (status === AssetMediaStatus.Duplicate) { if (responseData.status === AssetMediaStatus.Duplicate) {
uploadAssetsStore.duplicateCounter.update((count) => count + 1); uploadAssetsStore.duplicateCounter.update((count) => count + 1);
} else { } else {
uploadAssetsStore.successCounter.update((c) => c + 1); uploadAssetsStore.successCounter.update((c) => c + 1);
if (albumId && id) { }
uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Adding to album...' });
await addAssetsToAlbum(albumId, [id]); if (albumId) {
uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Added to album' }); uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Adding to album...' });
} await addAssetsToAlbum(albumId, [responseData.id]);
uploadAssetsStore.updateAsset(deviceAssetId, { message: 'Added to album' });
} }
uploadAssetsStore.updateAsset(deviceAssetId, { uploadAssetsStore.updateAsset(deviceAssetId, {
state: status === AssetMediaStatus.Duplicate ? UploadState.DUPLICATED : UploadState.DONE, state: responseData.status === AssetMediaStatus.Duplicate ? UploadState.DUPLICATED : UploadState.DONE,
}); });
setTimeout(() => { setTimeout(() => {
uploadAssetsStore.removeUploadAsset(deviceAssetId); uploadAssetsStore.removeUploadAsset(deviceAssetId);
}, 1000); }, 1000);
return id; return responseData.id;
} catch (error) { } catch (error) {
handleError(error, 'Unable to upload file'); handleError(error, 'Unable to upload file');
const reason = getServerErrorMessage(error) || error; const reason = getServerErrorMessage(error) || error;