feat(web): better UX when creating a new album (#8270)

* feat(web): ask user before going to newly created album

* feat(web): add button option to notification cards

* feat(web): allow html messages in notification cards

* show album -> view album

* remove 'link' action from notifications

* remove unused type
This commit is contained in:
Ethan Margaillan
2024-03-27 20:47:42 +01:00
committed by GitHub
parent 613b544bf0
commit 8bf571bf48
8 changed files with 134 additions and 54 deletions

View File

@@ -1,19 +1,14 @@
<script lang="ts">
import { goto } from '$app/navigation';
import AlbumSelectionModal from '$lib/components/shared-components/album-selection-modal.svelte';
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
import {
NotificationType,
notificationController,
} from '$lib/components/shared-components/notification/notification';
import { AppRoute } from '$lib/constants';
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
import { createAlbum, type AlbumResponseDto } from '@immich/sdk';
import { addAssetsToAlbum, addAssetsToNewAlbum } from '$lib/utils/asset-utils';
import type { AlbumResponseDto } from '@immich/sdk';
import { getMenuContext } from '../asset-select-context-menu.svelte';
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
import { mdiImageAlbum, mdiShareVariantOutline } from '@mdi/js';
export let shared = false;
let showAlbumPicker = false;
const { getAssets, clearSelect } = getAssetControlContext();
@@ -24,26 +19,12 @@
closeMenu();
};
const handleAddToNewAlbum = (albumName: string) => {
const handleAddToNewAlbum = async (albumName: string) => {
showAlbumPicker = false;
closeMenu();
const assetIds = [...getAssets()].map((asset) => asset.id);
createAlbum({ createAlbumDto: { albumName, assetIds } })
.then(async (response) => {
const { id, albumName } = response;
notificationController.show({
message: `Added ${assetIds.length} to ${albumName}`,
type: NotificationType.Info,
});
clearSelect();
await goto(`${AppRoute.ALBUMS}/${id}`);
})
.catch((error) => {
console.error(`[add-to-album.svelte]:handleAddToNewAlbum ${error}`, error);
});
await addAssetsToNewAlbum(albumName, assetIds);
};
const handleAddToAlbum = async (album: AlbumResponseDto) => {