Fixed upload asset to album in asset selection (#579)

* Fixed error uploading a file from album

* Fixed album selection mode show viewing asset stage

* Navigate back after uploading asset to album
This commit is contained in:
Alex 2022-09-05 00:18:53 -05:00 committed by GitHub
parent 172eda3ce5
commit 6976a7241e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 13 deletions

View file

@ -209,7 +209,6 @@
const createAlbumHandler = async (event: CustomEvent) => {
const { assets }: { assets: AssetResponseDto[] } = event.detail;
try {
const { data } = await api.albumApi.addAssetsToAlbum(album.id, {
assetIds: assets.map((a) => a.id)
@ -226,6 +225,22 @@
}
};
const assetUploadedToAlbumHandler = async (event: CustomEvent) => {
const { assetIds }: { assetIds: string[] } = event.detail;
try {
const { data } = await api.albumApi.addAssetsToAlbum(album.id, {
assetIds: assetIds
});
album = data;
} catch (e) {
console.error('Error [assetUploadedToAlbumHandler] ', e);
notificationController.show({
type: NotificationType.Error,
message: 'Error adding asset to album, check console for more details'
});
}
};
const addUserHandler = async (event: CustomEvent) => {
const { selectedUsers }: { selectedUsers: UserResponseDto[] } = event.detail;
@ -480,6 +495,7 @@
assetsInAlbum={album.assets}
on:go-back={() => (isShowAssetSelection = false)}
on:create-album={createAlbumHandler}
on:asset-uploaded={assetUploadedToAlbumHandler}
/>
{/if}

View file

@ -39,20 +39,23 @@
$: {
if (uploadAssets.length == uploadAssetsCount) {
// Filter assets that are already in the album
const assetsToAdd = uploadAssets.filter(
const assetIds = uploadAssets.filter(
(asset) => !!asset && !assetsInAlbum.some((a) => a.id === asset)
);
// Add the just uploaded assets to the album
if (assetsToAdd.length) {
dispatch('create-album', {
assets: assetsToAdd
if (assetIds.length) {
dispatch('asset-uploaded', {
assetIds
});
}
// Clean up states.
albumUploadAssetStore.asset.set([]);
albumUploadAssetStore.count.set(9999);
assetInteractionStore.clearMultiselect();
dispatch('go-back');
}
}
@ -99,6 +102,6 @@
</svelte:fragment>
</ControlAppBar>
<section class="pt-[100px] pl-[70px] grid h-screen bg-immich-bg">
<AssetGrid />
<AssetGrid isAlbumSelectionMode={true} />
</section>
</section>