diff --git a/web/src/lib/services/trash.service.ts b/web/src/lib/services/trash.service.ts index 10731b9f0..3fbe7a91c 100644 --- a/web/src/lib/services/trash.service.ts +++ b/web/src/lib/services/trash.service.ts @@ -5,23 +5,25 @@ import type { MessageFormatter } from 'svelte-i18n'; import { handleError } from '$lib/utils/handle-error'; import { getFormatter } from '$lib/utils/i18n'; -export const getTrashActions = ($t: MessageFormatter) => { +export const getTrashActions = ($t: MessageFormatter, assetCount: number) => { const RestoreAll: ActionItem = { title: $t('restore_all'), icon: mdiHistory, + $if: () => assetCount > 0, onAction: () => handleRestoreTrash(), }; const Empty: ActionItem = { title: $t('empty_trash'), icon: mdiDeleteForeverOutline, + $if: () => assetCount > 0, onAction: () => handleEmptyTrash(), }; return { RestoreAll, Empty }; }; -export const handleEmptyTrash = async () => { +const handleEmptyTrash = async () => { const $t = await getFormatter(); const confirmed = await modalManager.showDialog({ prompt: $t('empty_trash_confirmation') }); @@ -37,7 +39,7 @@ export const handleEmptyTrash = async () => { } }; -export const handleRestoreTrash = async () => { +const handleRestoreTrash = async () => { const $t = await getFormatter(); const confirmed = await modalManager.showDialog({ prompt: $t('assets_restore_confirmation') }); diff --git a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte index 228cd58c3..46e8b46be 100644 --- a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -40,7 +40,7 @@ return; }; - const { Empty, RestoreAll } = $derived(getTrashActions($t)); + const { Empty, RestoreAll } = $derived(getTrashActions($t, timelineManager?.assetCount ?? 0)); {#if featureFlagsManager.value.trash}