High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(web): add leave album action (#31768)
kojomba253692f2793b
diff --git a/web/src/lib/components/album-page/AlbumCardGroup.svelte b/web/src/lib/components/album-page/AlbumCardGroup.svelteindex 94710ecd32..68d9829684 100644--- a/web/src/lib/components/album-page/AlbumCardGroup.svelte+++ b/web/src/lib/components/album-page/AlbumCardGroup.svelte@@ -66,8 +66,8 @@{#if !isCollapsed}<div class="grid grid-auto-fill-56 gap-y-4" transition:slide={{ duration: 300 }}>{#each albums as album, index (album.id)}- {@const { Edit, Share, Download, Delete } = getAlbumActions($t, album)}- {@const items = [Edit, Share, Download, Delete]}+ {@const { Edit, Share, Download, Leave, Delete } = getAlbumActions($t, album)}+ {@const items = [Edit, Share, Download, Leave, Delete]}<ahref={Route.viewAlbum(album)}class="h-fit"diff --git a/web/src/lib/components/album-page/AlbumsTableRow.svelte b/web/src/lib/components/album-page/AlbumsTableRow.svelteindex 3371bb47a4..1ff9f33a1f 100644--- a/web/src/lib/components/album-page/AlbumsTableRow.svelte+++ b/web/src/lib/components/album-page/AlbumsTableRow.svelte@@ -19,8 +19,8 @@let contextMenuAnchor: HTMLDivElement | undefined = $state();const items = $derived.by(() => {- const { Edit, Share, Download, Delete } = getAlbumActions($t, album);- return [Edit, Share, Download, Delete];+ const { Edit, Share, Download, Leave, Delete } = getAlbumActions($t, album);+ return [Edit, Share, Download, Leave, Delete];});const dateLocaleString = (dateString: string) => {diff --git a/web/src/lib/services/album.service.ts b/web/src/lib/services/album.service.tsindex b5570d35b2..862456cae1 100644--- a/web/src/lib/services/album.service.ts+++ b/web/src/lib/services/album.service.ts@@ -25,6 +25,7 @@ import {mdiRenameOutline,mdiShareVariantOutline,mdiTrashCanOutline,+ mdiExitToApp,mdiUpload,} from '@mdi/js';import { type MessageFormatter } from 'svelte-i18n';@@ -37,6 +38,7 @@ import AlbumEditModal from '$lib/modals/AlbumEditModal.svelte';import AlbumOptionsModal from '$lib/modals/AlbumOptionsModal.svelte';import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';import { Route } from '$lib/route';+import { userInteraction } from '$lib/stores/user.svelte';import { createAlbumAndRedirect } from '$lib/utils/album-utils';import { downloadArchive } from '$lib/utils/asset-utils';import { openFileUploadDialog } from '$lib/utils/file-uploader';@@ -83,6 +85,13 @@ export const getAlbumActions = ($t: MessageFormatter, album: AlbumResponseDto) =onAction: () => handleDownloadAlbum(album),};+ const Leave: ActionItem = {+ title: $t('leave_album'),+ icon: mdiExitToApp,+ $if: () => !isOwned,+ onAction: () => handleLeaveAlbum(album),+ };+const Edit: ActionItem = {title: $t('edit_album'),icon: mdiRenameOutline,@@ -97,7 +106,7 @@ export const getAlbumActions = ($t: MessageFormatter, album: AlbumResponseDto) =onAction: () => modalManager.show(AlbumOptionsModal, { album }),};- return { AddUsers, CreateSharedLink, Delete, Download, Edit, Share };+ return { AddUsers, CreateSharedLink, Delete, Download, Edit, Leave, Share };};export const getAlbumAssetActions = ($t: MessageFormatter, album: AlbumResponseDto, asset: AssetResponseDto) => {@@ -257,6 +266,29 @@ export const handleRemoveUserFromAlbum = async (album: AlbumResponseDto, albumUs}};+export const handleLeaveAlbum = async (album: AlbumResponseDto) => {+ const $t = await getFormatter();++ const confirmed = await modalManager.showDialog({+ title: $t('leave_album'),+ prompt: $t('are_you_sure_to_do_this'),+ confirmText: $t('leave'),+ });++ if (!confirmed) {+ return;+ }++ try {+ await removeUserFromAlbum({ id: album.id, userId: 'me' });+ userInteraction.recentAlbums = undefined;+ eventManager.emit('AlbumDelete', album);+ return true;+ } catch (error) {+ handleError(error, $t('errors.unable_to_remove_album_users'));+ }+};+const handleUpdateThumbnail = async (album: AlbumResponseDto, assetId: string) => {const $t = await getFormatter();diff --git a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelteindex 641e4728cb..6e144d06e9 100644--- a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte+++ b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.svelte@@ -328,7 +328,7 @@};const { Cast } = $derived(getGlobalActions($t));- const { Share } = $derived(getAlbumActions($t, album));+ const { Share, Leave } = $derived(getAlbumActions($t, album));const { AddAssets, Upload } = $derived(getAlbumAssetsActions($t, album, timelineMultiSelectManager.assets));const Close = $derived({@@ -561,7 +561,7 @@/>{/if}- {#if isOwned || containsEditors}+ {#if isOwned || album.albumUsers.length > 1}<ButtonContextMenuicon={mdiDotsVertical}title={$t('album_options')}@@ -594,6 +594,8 @@text={$t('delete_album')}onClick={() => handleDeleteAlbum(album)}/>+ {:else}+ <ActionMenuItem action={Leave} />{/if}</ButtonContextMenu>{/if}